Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<#
.SYNOPSIS

Builds and runs tests for the Complex Calculator project
#>
if (-not (Get-Command MsBuild -ErrorAction SilentlyContinue))
{
Get-VsVars32
}

MSBuild .\src\ComplexCalculator\ComplexCalculator.sln

if ($LASTEXITCODE -eq 0)
{
.\src\ComplexCalculator\packages\xunit.runner.console.2.3.0-beta3-build3705\tools\net452\xunit.console.exe .\src\ComplexCalculator.Tests\bin\Debug\ComplexCalculator.Tests.dll
}

exit $LASTEXITCODE
10 changes: 9 additions & 1 deletion src/ComplexCalculator.Tests/ComplexCalculator.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\ComplexCalculator\packages\xunit.runner.console.2.3.0-beta3-build3705\build\xunit.runner.console.props" Condition="Exists('..\ComplexCalculator\packages\xunit.runner.console.2.3.0-beta3-build3705\build\xunit.runner.console.props')" />
<Import Project="..\ComplexCalculator\packages\xunit.runner.visualstudio.2.3.0-beta3-build3705\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\ComplexCalculator\packages\xunit.runner.visualstudio.2.3.0-beta3-build3705\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="..\ComplexCalculator\packages\xunit.core.2.3.0-beta3-build3705\build\xunit.core.props" Condition="Exists('..\ComplexCalculator\packages\xunit.core.2.3.0-beta3-build3705\build\xunit.core.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
Expand Down Expand Up @@ -56,7 +57,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="TestClass.cs" />
<Compile Include="ComplexNumberTestClass.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand All @@ -68,6 +69,12 @@
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ComplexCalculator\ComplexCalculator.csproj">
<Project>{75d70f12-d503-450e-9ec8-d32be6491aef}</Project>
<Name>ComplexCalculator</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
Expand All @@ -76,6 +83,7 @@
<Error Condition="!Exists('..\ComplexCalculator\packages\xunit.core.2.3.0-beta3-build3705\build\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\ComplexCalculator\packages\xunit.core.2.3.0-beta3-build3705\build\xunit.core.props'))" />
<Error Condition="!Exists('..\ComplexCalculator\packages\xunit.core.2.3.0-beta3-build3705\build\xunit.core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\ComplexCalculator\packages\xunit.core.2.3.0-beta3-build3705\build\xunit.core.targets'))" />
<Error Condition="!Exists('..\ComplexCalculator\packages\xunit.runner.visualstudio.2.3.0-beta3-build3705\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\ComplexCalculator\packages\xunit.runner.visualstudio.2.3.0-beta3-build3705\build\net20\xunit.runner.visualstudio.props'))" />
<Error Condition="!Exists('..\ComplexCalculator\packages\xunit.runner.console.2.3.0-beta3-build3705\build\xunit.runner.console.props')" Text="$([System.String]::Format('$(ErrorText)', '..\ComplexCalculator\packages\xunit.runner.console.2.3.0-beta3-build3705\build\xunit.runner.console.props'))" />
</Target>
<Import Project="..\ComplexCalculator\packages\xunit.core.2.3.0-beta3-build3705\build\xunit.core.targets" Condition="Exists('..\ComplexCalculator\packages\xunit.core.2.3.0-beta3-build3705\build\xunit.core.targets')" />
</Project>
46 changes: 46 additions & 0 deletions src/ComplexCalculator.Tests/ComplexNumberTestClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Xunit;

namespace ComplexCalculator.Tests
{
public class ComplexNumberTestClass
{
[Fact]
public void WhenRealPartSet_ItCanBeReturned()
{
// Arrange
var num = new ComplexNumber();

// Act
num.Real = 42;

// Assert
Assert.Equal(42, num.Real);
}

[Fact]
public void WhenImaginaryPartSet_ItCanBeReturned()
{
// Arrange
var num = new ComplexNumber();

// Act
num.Imaginary = 13;

// Assert
Assert.Equal(13, num.Imaginary);
}

[Fact]
public void WhenModulousIsCalled_ItIsCalculatedAndReturned()
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Modulus not Modulous

{
// Arrange
var num = new ComplexNumber { Real = 3, Imaginary = 4 };

// Act
var mod = num.Modulous();
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Modulus not Modulous


// Assert
Assert.Equal(5, mod);
}
}
}
18 changes: 0 additions & 18 deletions src/ComplexCalculator.Tests/TestClass.cs

This file was deleted.

1 change: 1 addition & 0 deletions src/ComplexCalculator.Tests/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
<package id="xunit.core" version="2.3.0-beta3-build3705" targetFramework="net452" />
<package id="xunit.extensibility.core" version="2.3.0-beta3-build3705" targetFramework="net452" />
<package id="xunit.extensibility.execution" version="2.3.0-beta3-build3705" targetFramework="net452" />
<package id="xunit.runner.console" version="2.3.0-beta3-build3705" targetFramework="net452" developmentDependency="true" />
<package id="xunit.runner.visualstudio" version="2.3.0-beta3-build3705" targetFramework="net452" developmentDependency="true" />
</packages>
1 change: 1 addition & 0 deletions src/ComplexCalculator/ComplexCalculator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ComplexNumber.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down
16 changes: 16 additions & 0 deletions src/ComplexCalculator/ComplexNumber.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace ComplexCalculator
{
public class ComplexNumber
{
public double Real { get; set; }

public double Imaginary { get; set; }

public double Modulous()
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Modulus not Modulous

{
return Math.Sqrt(Real * Real + Imaginary * Imaginary);
}
}
}
4 changes: 0 additions & 4 deletions src/ComplexCalculator/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ComplexCalculator
{
Expand Down