Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all 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
99 changes: 24 additions & 75 deletions Amido.NAuto.IntegrationTests/Amido.NAuto.IntegrationTests.csproj
Original file line number Diff line number Diff line change
@@ -1,87 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4A052FBA-43C7-408F-AFEE-701B03F4CC98}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Amido.NAuto.IntegrationTests</RootNamespace>
<AssemblyName>Amido.NAuto.IntegrationTests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RunCodeAnalysis>true</RunCodeAnalysis>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>

<PropertyGroup>
<TargetFrameworks>net40;netcoreapp1.0</TargetFrameworks>
<AssemblyName>Amido.NAuto.IntegrationTests</AssemblyName>
<PackageId>Amido.NAuto.IntegrationTests</PackageId>
</PropertyGroup>

<ItemGroup>
<Reference Include="nunit.framework, Version=3.8.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.8.1\lib\net40\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Should">
<HintPath>..\packages\Should.1.1.20\lib\Should.dll</HintPath>
</Reference>
<Reference Include="System" />
<PackageReference Include="Shouldly" Version="3.0.0" />
<PackageReference Include="NUnit" Version="3.9.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net40'">
<PackageReference Include="Moq" Version="4.1.1311.0615" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AutoBuilderTests.cs" />
<Compile Include="BuilderTests.cs" />
<Compile Include="GetRandomIntegerTests.cs" />
<Compile Include="GetRandomPropertyTypeTests.cs" />
<Compile Include="GetRandomStringTests.cs" />
<Compile Include="Helpers\CustomBuilder.cs" />
<Compile Include="Helpers\TestAnnotationModelIntegrationTests.cs" />
<Compile Include="Helpers\TestModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RandomListGeneratorTests.cs" />
<Compile Include="WrapperClassTest.cs" />

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp1.0'">
<PackageReference Include="Moq" Version="4.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.4.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Amido.NAuto\Amido.NAuto.csproj">
<Project>{29062f9c-5a4b-4a6d-a71d-42de6d5a8d9d}</Project>
<Name>Amido.NAuto</Name>
</ProjectReference>
<ProjectReference Include="..\Amido.NAuto\Amido.NAuto.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="packages.config" />
<None Include="TestJsonModels\testModel3.json" />
<None Include="TestJsonModels\testModel4.json" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->

</Project>
101 changes: 54 additions & 47 deletions Amido.NAuto.IntegrationTests/AutoBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Amido.NAuto.IntegrationTests.Helpers;
using Amido.NAuto.Randomizers;
using NUnit.Framework;
using Should;
using Shouldly;

namespace Amido.NAuto.IntegrationTests
{
Expand All @@ -24,7 +24,7 @@ public void Should_Create_Empty_Instance_Of_Model()
.Build();

testModel.ShouldNotBeNull();
testModel.Email.ShouldEqual(Email);
testModel.Email.ShouldBe(Email);
}

[Test]
Expand Down Expand Up @@ -62,7 +62,7 @@ public void Should_Persist_Json_Representation()
public void Should_Use_Data_Annotation_Email_Type_As_Convention()
{
var testModel = NAuto.AutoBuild<TestAnnotationModelIntegrationTests>()
.ClearConventions()
.ClearConventions()
.Construct()
.Build();

Expand Down Expand Up @@ -106,8 +106,9 @@ public void Should_Use_Nullable_Int_Range_Data_Annotation_As_Convention()
.Build();

// Assert
testModel.RangeNullableIntTest.ShouldBeGreaterThanOrEqualTo(1);
testModel.RangeNullableIntTest.ShouldBeLessThanOrEqualTo(10);
Assert.IsTrue(testModel.RangeNullableIntTest.HasValue);
testModel.RangeNullableIntTest.Value.ShouldBeGreaterThanOrEqualTo(1);
testModel.RangeNullableIntTest.Value.ShouldBeLessThanOrEqualTo(10);
}

[Test]
Expand All @@ -119,16 +120,17 @@ public void Should_Use_Nullable_Double_Range_Data_Annotation_As_Convention()
.Build();

// Assert
testModel.RangeNullableDoubleTest.ShouldBeGreaterThanOrEqualTo(1);
testModel.RangeNullableDoubleTest.ShouldBeLessThanOrEqualTo(10);
Assert.IsTrue(testModel.RangeNullableDoubleTest.HasValue);
testModel.RangeNullableDoubleTest.Value.ShouldBeGreaterThanOrEqualTo(1);
testModel.RangeNullableDoubleTest.Value.ShouldBeLessThanOrEqualTo(10);
}

[Test]
public void Should_Construct_List_Based_Top_Level_Models_With_Parameters()
{
// Arrange
var testListParameter = new List<TestModel>();
testListParameter.Add(new TestModel{FirstName = "Sean"});
testListParameter.Add(new TestModel { FirstName = "Sean" });
// Act
var testList = NAuto.AutoBuild<List<TestModel>>()
.Construct(testListParameter)
Expand Down Expand Up @@ -175,16 +177,18 @@ public void Should_Return_New_Model_Automatically_Populated()
testModel.FirstName.ShouldNotBeEmpty();
testModel.LastName.ShouldNotBeEmpty();
testModel.Byte.ShouldBeGreaterThan((byte)0);
testModel.NullableByte.ShouldBeGreaterThan((byte)0);
testModel.Bytes.Length.ShouldEqual(configuration.DefaultCollectionItemCount);
testModel.NullableBytes.Length.ShouldEqual(configuration.DefaultCollectionItemCount);
testModel.FavouriteInteger.ShouldNotEqual(default(int));
testModel.FavouriteDouble.ShouldNotEqual(default(double));
testModel.FavouriteDateTime.ShouldNotEqual(default(DateTime));
testModel.SubTestModel.SubDateTime.ShouldNotEqual(default(DateTime));
testModel.SubTestModel.SubDouble.ShouldNotEqual(default(double));
testModel.SubTestModel.SubInteger.ShouldNotEqual(default(int));
Assert.IsTrue(testModel.NullableByte.HasValue);
testModel.NullableByte.Value.ShouldBeGreaterThan((byte)0);
testModel.Bytes.Length.ShouldBe(configuration.DefaultCollectionItemCount);
testModel.NullableBytes.Length.ShouldBe(configuration.DefaultCollectionItemCount);
testModel.FavouriteInteger.ShouldNotBe(default(int));
testModel.FavouriteDouble.ShouldNotBe(default(double));
testModel.FavouriteDateTime.ShouldNotBe(default(DateTime));
testModel.SubTestModel.SubDateTime.ShouldNotBe(default(DateTime));
testModel.SubTestModel.SubDouble.ShouldNotBe(default(double));
testModel.SubTestModel.SubInteger.ShouldNotBe(default(int));
testModel.SubTestModel.SubString.ShouldNotBeEmpty();
Assert.IsTrue(testModel.SubTestModel.SubBool.HasValue);
testModel.SubTestModel.SubBool.Value.ShouldBeTrue();
}

Expand All @@ -200,16 +204,17 @@ public void Should_Return_New_Model_Automatically_Populated_With_Override()
.Build();

// Assert
testModel.SubTestModel.SubString.ShouldEqual(overridden);
testModel.SubTestModel.SubString.ShouldBe(overridden);

testModel.FirstName.ShouldNotBeEmpty();
testModel.LastName.ShouldNotBeEmpty();
testModel.FavouriteInteger.ShouldNotEqual(default(int));
testModel.FavouriteDouble.ShouldNotEqual(default(double));
testModel.FavouriteDateTime.ShouldNotEqual(default(DateTime));
testModel.SubTestModel.SubDateTime.ShouldNotEqual(default(DateTime));
testModel.SubTestModel.SubDouble.ShouldNotEqual(default(double));
testModel.SubTestModel.SubInteger.ShouldNotEqual(default(int));
testModel.FavouriteInteger.ShouldNotBe(default(int));
testModel.FavouriteDouble.ShouldNotBe(default(double));
testModel.FavouriteDateTime.ShouldNotBe(default(DateTime));
testModel.SubTestModel.SubDateTime.ShouldNotBe(default(DateTime));
testModel.SubTestModel.SubDouble.ShouldNotBe(default(double));
testModel.SubTestModel.SubInteger.ShouldNotBe(default(int));
Assert.IsTrue(testModel.SubTestModel.SubBool.HasValue);
testModel.SubTestModel.SubBool.Value.ShouldBeTrue();
}

Expand All @@ -223,7 +228,7 @@ public void Should_Return_Model_With_Updated_Random_Settings_For_Top_Level_Prope
.Build();

// Assert
testModel.FirstName.Length.ShouldEqual(9);
testModel.FirstName.Length.ShouldBe(9);
}

[Test]
Expand All @@ -236,7 +241,7 @@ public void Should_Return_Model_With_Updated_Random_Settings_For_2_Levels_Deep_P
.Build();

// Assert
testModel.SubTestModel.SubString.Length.ShouldEqual(7);
testModel.SubTestModel.SubString.Length.ShouldBe(7);
}

[Test]
Expand All @@ -250,8 +255,8 @@ public void Should_Return_Model_With_Updated_Random_Settings_For_3_Levels_Deep_P
.Build();

// Assert
testModel.SubTestModel.SubSubTestModel.SubSubString.Length.ShouldEqual(5);
testModel.SubTestModel.SubString.Length.ShouldEqual(12);
testModel.SubTestModel.SubSubTestModel.SubSubString.Length.ShouldBe(5);
testModel.SubTestModel.SubString.Length.ShouldBe(12);
}


Expand Down Expand Up @@ -279,8 +284,9 @@ public void Should_Return_Model_With_Updated_Random_Settings_For_2nd_Level_Integ
.Build();

// Assert
testModel.SubTestModel.SubInteger.ShouldBeGreaterThanOrEqualTo(100);
testModel.SubTestModel.SubInteger.ShouldBeLessThanOrEqualTo(103);
Assert.IsTrue(testModel.SubTestModel.SubInteger.HasValue);
testModel.SubTestModel.SubInteger.Value.ShouldBeGreaterThanOrEqualTo(100);
testModel.SubTestModel.SubInteger.Value.ShouldBeLessThanOrEqualTo(103);
}

[Test]
Expand Down Expand Up @@ -321,8 +327,9 @@ public void Should_Return_Model_With_Updated_Random_Settings_For_2nd_Level_Doubl
.Build();

// Assert
testModel.SubTestModel.SubDouble.ShouldBeGreaterThanOrEqualTo(100);
testModel.SubTestModel.SubDouble.ShouldBeLessThanOrEqualTo(103);
Assert.IsTrue(testModel.SubTestModel.SubDouble.HasValue);
testModel.SubTestModel.SubDouble.Value.ShouldBeGreaterThanOrEqualTo(100);
testModel.SubTestModel.SubDouble.Value.ShouldBeLessThanOrEqualTo(103);
}

[Test]
Expand All @@ -345,7 +352,7 @@ public void Should_Override_Properties_Data_Generation()
// Arrange
const int minLength = 5;
const int maxLength = 50;
var config = new AutoBuilderConfiguration(stringMinLength:minLength, stringMaxLength:maxLength);
var config = new AutoBuilderConfiguration(stringMinLength: minLength, stringMaxLength: maxLength);

// Act
var testModel = NAuto.AutoBuild<TestModel>(config)
Expand Down Expand Up @@ -373,7 +380,7 @@ public void Should_Override_Property_With_Random_Email()
testModel.SubTestModel.SubEmail.ShouldContain("@");
testModel.SubTestModel.SubSubTestModel.SubSubEmail.ShouldContain("@");
}

[Test]
public void Should_Not_Exceed_Max_Depth_Default()
{
Expand All @@ -390,7 +397,7 @@ public void Should_Not_Exceed_Max_Depth_Default()
public void Should_Not_Exceed_Max_Depth_Default_Of_Override_Depth_Of_4()
{
// Act
var testModel = NAuto.AutoBuild<TestModel>(new AutoBuilderConfiguration(maxDepth:4))
var testModel = NAuto.AutoBuild<TestModel>(new AutoBuilderConfiguration(maxDepth: 4))
.Construct()
.Build();

Expand All @@ -407,7 +414,7 @@ public void Should_Add_Simple_Item_ToArray()
.Build();

// Assert
testModel.SubTestModel.SimpleArray.Length.ShouldEqual(configuration.DefaultCollectionItemCount);
testModel.SubTestModel.SimpleArray.Length.ShouldBe(configuration.DefaultCollectionItemCount);
}

[Test]
Expand All @@ -419,7 +426,7 @@ public void Should_Add_Complex_Item_ToArray()
.Build();

// Assert
testModel.FavouriteComplexArray.Length.ShouldEqual(configuration.DefaultCollectionItemCount);
testModel.FavouriteComplexArray.Length.ShouldBe(configuration.DefaultCollectionItemCount);
}

[Test]
Expand All @@ -440,7 +447,7 @@ public void Should_Add_Multiple_String_Collections()
.Build();

// Assert
testModel.FavouriteStrings.Count.ShouldEqual(configuration.DefaultCollectionItemCount);
testModel.FavouriteStrings.Count.ShouldBe(configuration.DefaultCollectionItemCount);
}

[Test]
Expand Down Expand Up @@ -471,14 +478,14 @@ public void Should_Override_Property_With_Custom_Convention()
var autoTestBuilderConfiguration = new AutoBuilderConfiguration();

autoTestBuilderConfiguration.Conventions.Add(new ConventionMap(ConventionFilterType.Contains, "PetName", typeof(string), config => "Rex"));

var conventionsTestModel = NAuto.AutoBuild<ConventionsModel>(autoTestBuilderConfiguration)
.Construct()
.Build();

// Assert
conventionsTestModel.PetName.ShouldEqual("Rex");
conventionsTestModel.SubConventionsModel.PetName.ShouldEqual("Rex");
conventionsTestModel.PetName.ShouldBe("Rex");
conventionsTestModel.SubConventionsModel.PetName.ShouldBe("Rex");
}

[Test]
Expand All @@ -489,7 +496,7 @@ public void Should_Construct_Using_Argument_And_Populate_PrivateSetter()
.Build();

// Assert
noDefautConstructor.FirstName.ShouldEqual("Blah");
noDefautConstructor.FirstName.ShouldBe("Blah");
}

[Test]
Expand Down Expand Up @@ -527,7 +534,7 @@ public void Should_Throw_Exception_If_Interface_Used_As_Type_Argument()
.Construct()
.Build());

exception.Message.ShouldEqual("Can't instantiate interfaces");
exception.Message.ShouldBe("Can't instantiate interfaces");
}

[Test]
Expand All @@ -537,7 +544,7 @@ public void Should_Throw_Exception_If_Abstract_Class_Used_As_Type_Argument()
.Construct()
.Build());

exception.Message.ShouldEqual("Can't instantiate abstract classes");
exception.Message.ShouldBe("Can't instantiate abstract classes");
}

[Test]
Expand All @@ -560,7 +567,7 @@ public void Should_Use_Chinese_CharacterSet()
.Construct()
.Build();

testModel.ShouldNotBeNull();
testModel.ShouldNotBeNull();
}

[Test]
Expand Down Expand Up @@ -598,10 +605,10 @@ public void Should_Follow_If_Then_Logic()
.Then(x => x.LastName = "Blah")
.Build();

model.LastName.ShouldEqual("Blah");
model.LastName.ShouldBe("Blah");
}

public interface IMyInterface{}
public interface IMyInterface { }

public abstract class MyAbstractClass
{
Expand Down
Loading