Skip to content

Commit

Permalink
[r] shared models made less shared, remvod unused parameters
Browse files Browse the repository at this point in the history
[r] redundant async
  • Loading branch information
i4004 committed Mar 25, 2024
1 parent 73bef68 commit 690f8cd
Show file tree
Hide file tree
Showing 55 changed files with 204 additions and 93 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System;
using System.Linq;
using NUnit.Framework;
using Simplify.Web.Meta;
using Simplify.Web.Tests.TestEntities;
using Simplify.Web.Meta.Tests.TestTypes;

namespace Simplify.Web.Tests.Meta;
namespace Simplify.Web.Meta.Tests;

[TestFixture]
public class ControllersMetaDataFactoryTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
using Moq;
using NUnit.Framework;
using Simplify.Web.Attributes.Setup;
using Simplify.Web.Meta;
using Simplify.Web.Tests.TestEntities;
using Simplify.Web.Meta.Tests.TestTypes;

namespace Simplify.Web.Tests.Meta;
namespace Simplify.Web.Meta.Tests;

[TestFixture]
[IgnoreControllers(typeof(TestController3))]
Expand Down
22 changes: 22 additions & 0 deletions src/Simplify.Web.Meta.Tests/Simplify.Web.Meta.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>

<Authors>Alexander Krylkov</Authors>
<Product>Simplify</Product>
<Description>Simplify.Web meta unit tests</Description>
<Copyright>Licensed under LGPL</Copyright>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Simplify.Web\Simplify.Web.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.*" />
<PackageReference Include="Moq" Version="4.20.*" />
<PackageReference Include="NUnit" Version="3.14.*" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.*" />
<PackageReference Include="Simplify.Xml" Version="1.3.*" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using NUnit.Framework;
using Simplify.Web.Bootstrapper;
using Simplify.Web.Meta;
using Simplify.Web.Tests.TestEntities;
using Simplify.Web.Meta.Tests.TestTypes;

namespace Simplify.Web.Tests.Meta;
namespace Simplify.Web.Meta.Tests;

[TestFixture]
public class SimplifyWebTypesFinderTests
Expand All @@ -23,7 +22,7 @@ public void FindTypeDerivedFrom_BaseBootstrapper_TestBootstrapperReturned()
var type = SimplifyWebTypesFinder.FindTypeDerivedFrom<BaseBootstrapper>();

// Assert
Assert.AreEqual("Simplify.Web.Tests.TestEntities.TestBootstrapper", type!.FullName);
Assert.AreEqual("Simplify.Web.Meta.Tests.TestTypes.TestBootstrapper", type!.FullName);
}

[Test]
Expand All @@ -45,9 +44,9 @@ public void FindTypesDerivedFrom_ControllerWith3TypesDerived_3TestControllersRet
// Assert

Assert.AreEqual(3, types.Count);
Assert.AreEqual("Simplify.Web.Tests.TestEntities.TestController1", types[0].FullName);
Assert.AreEqual("Simplify.Web.Tests.TestEntities.TestController3", types[1].FullName);
Assert.AreEqual("Simplify.Web.Tests.TestEntities.TestController6", types[2].FullName);
Assert.AreEqual("Simplify.Web.Meta.Tests.TestTypes.TestController1", types[0].FullName);
Assert.AreEqual("Simplify.Web.Meta.Tests.TestTypes.TestController3", types[1].FullName);
Assert.AreEqual("Simplify.Web.Meta.Tests.TestTypes.TestController6", types[2].FullName);
}

[Test]
Expand All @@ -59,7 +58,7 @@ public void FindTypesDerivedFrom_ControllerWithModelWith1TypeDerived_1TestContro
// Assert

Assert.AreEqual(1, types.Count);
Assert.AreEqual("Simplify.Web.Tests.TestEntities.TestController4", types[0].FullName);
Assert.AreEqual("Simplify.Web.Meta.Tests.TestTypes.TestController4", types[0].FullName);
}

[Test]
Expand All @@ -71,7 +70,7 @@ public void FindTypesDerivedFrom_AsyncControllerWith1TypeDerived_1TestController
// Assert

Assert.AreEqual(1, types.Count);
Assert.AreEqual("Simplify.Web.Tests.TestEntities.TestController2", types[0].FullName);
Assert.AreEqual("Simplify.Web.Meta.Tests.TestTypes.TestController2", types[0].FullName);
}

[Test]
Expand All @@ -83,7 +82,7 @@ public void FindTypesDerivedFrom_AsyncControllerWithModelWith1TypeDerived_1TestC
// Assert

Assert.AreEqual(1, types.Count);
Assert.AreEqual("Simplify.Web.Tests.TestEntities.TestController5", types[0].FullName);
Assert.AreEqual("Simplify.Web.Meta.Tests.TestTypes.TestController5", types[0].FullName);
}

[Test]
Expand All @@ -95,7 +94,7 @@ public void FindTypesDerivedFrom_Controller2With1TypeDerived_1TestControllersRet
// Assert

Assert.AreEqual(1, types.Count);
Assert.AreEqual("Simplify.Web.Tests.TestEntities.TestControllerV2", types[0].FullName);
Assert.AreEqual("Simplify.Web.Meta.Tests.TestTypes.TestControllerV2", types[0].FullName);
}

[Test]
Expand All @@ -107,7 +106,7 @@ public void FindTypesDerivedFrom_Controller2WithModelWith1TypeDerived_1TestContr
// Assert

Assert.AreEqual(1, types.Count);
Assert.AreEqual("Simplify.Web.Tests.TestEntities.TestControllerV2WithModel", types[0].FullName);
Assert.AreEqual("Simplify.Web.Meta.Tests.TestTypes.TestControllerV2WithModel", types[0].FullName);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Simplify.Web.Tests.TestEntities;
namespace Simplify.Web.Meta.Tests.TestTypes;

public abstract class ControllerBase : Controller
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Simplify.Web.Bootstrapper;

namespace Simplify.Web.Tests.TestEntities;
namespace Simplify.Web.Meta.Tests.TestTypes;

public class TestBootstrapper : BaseBootstrapper
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Simplify.Web.Attributes;

namespace Simplify.Web.Tests.TestEntities;
namespace Simplify.Web.Meta.Tests.TestTypes;

[Get("/testaction")]
[Post("/testaction1")]
Expand Down
12 changes: 12 additions & 0 deletions src/Simplify.Web.Meta.Tests/TestTypes/TestController2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Threading.Tasks;

namespace Simplify.Web.Meta.Tests.TestTypes;

public class TestController2 : AsyncController
{
public override Task<ControllerResponse?> Invoke()
{
throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Simplify.Web.Tests.TestEntities;
namespace Simplify.Web.Meta.Tests.TestTypes;

public class TestController3 : Controller
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Simplify.Web.Tests.TestEntities;
namespace Simplify.Web.Meta.Tests.TestTypes;

public class TestController4 : Controller<TestModel>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Threading.Tasks;

namespace Simplify.Web.Tests.TestEntities;
namespace Simplify.Web.Meta.Tests.TestTypes;

public class TestController5 : AsyncController<TestModel>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Simplify.Web.Tests.TestEntities;
namespace Simplify.Web.Meta.Tests.TestTypes;

public class TestController6 : ControllerBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Simplify.Web.Attributes;

namespace Simplify.Web.Tests.TestEntities;
namespace Simplify.Web.Meta.Tests.TestTypes;

[Get("/testaction")]
public class TestControllerV2 : Controller2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Simplify.Web.Tests.TestEntities;
namespace Simplify.Web.Meta.Tests.TestTypes;

public class TestControllerV2WithModel : Controller2<TestModel>
{
Expand Down
6 changes: 6 additions & 0 deletions src/Simplify.Web.Meta.Tests/TestTypes/TestModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Simplify.Web.Meta.Tests.TestTypes;

public class TestModel
{
public string? Prop1 { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ public void CreateBootstrapper_HaveUserType_TestBootstrapperReturned()

// Assert

Assert.AreEqual("Simplify.Web.Tests.TestEntities.TestBootstrapper", bootstrapper.GetType().FullName);
Assert.AreEqual("Simplify.Web.Tests.Bootstrapper.TestTypes.TestBootstrapper", bootstrapper.GetType().FullName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Simplify.Web.Bootstrapper;

namespace Simplify.Web.Tests.Bootstrapper.TestTypes;

public class TestBootstrapper : BaseBootstrapper
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Simplify.Web.Core.Controllers;
using Simplify.Web.Meta;
using Simplify.Web.Routing;
using Simplify.Web.Tests.TestEntities;
using Simplify.Web.Tests.Core.Controllers.TestTypes;

namespace Simplify.Web.Tests.Core.Controllers;

Expand Down Expand Up @@ -418,7 +418,6 @@ public void IsSecurityRulesViolated_UserExistNotAuthenticatedUser_NotAuthenticat
[Test]
public void IsSecurityRulesViolated_UserExistNotAuthenticatedUserWithAllowedUserRoles_NotAuthenticated()
{

// Arrange

var metaData = Mock.Of<IControllerMetaData>(x => x.Security == new ControllerSecurity(true, new List<string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Simplify.Web.Meta;
using Simplify.Web.Modules;
using Simplify.Web.Routing;
using Simplify.Web.Tests.TestEntities;
using Simplify.Web.Tests.Core.Controllers.TestTypes;

namespace Simplify.Web.Tests.Core.Controllers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Moq;
using NUnit.Framework;
using Simplify.Web.Core.Controllers.Execution;
using Simplify.Web.Tests.TestEntities;
using Simplify.Web.Tests.Core.Controllers.Execution.Controller1TestTypes;

namespace Simplify.Web.Tests.Core.Controllers.Execution;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Simplify.Web.Tests.Core.Controllers.Execution.Controller1TestTypes;

public class TestModel
{
public string? Prop1 { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;

namespace Simplify.Web.Tests.Core.Controllers.TestTypes;

public class TestController1 : Controller
{
public override ControllerResponse Invoke() => throw new NotImplementedException();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Threading.Tasks;

namespace Simplify.Web.Tests.Core.Controllers.TestTypes;

public class TestController2 : AsyncController
{
public override Task<ControllerResponse?> Invoke()
{
throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;

namespace Simplify.Web.Tests.Core.Controllers.TestTypes;

public class TestController4 : Controller<TestModel>
{
public override ControllerResponse Invoke() => throw new NotImplementedException();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;
using System.Threading.Tasks;

namespace Simplify.Web.Tests.Core.Controllers.TestTypes;

public class TestController5 : AsyncController<TestModel>
{
public override Task<ControllerResponse?> Invoke() => throw new NotImplementedException();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Simplify.Web.Tests.Core.Controllers.TestTypes;

public class TestModel
{
public string? Prop1 { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using NUnit.Framework;
using Simplify.Web.Model.Binding;
using Simplify.Web.Model.Binding.Parsers;
using Simplify.Web.Tests.TestEntities;
using Simplify.Web.Tests.Model.Binding.Parsers.TestTypes;

namespace Simplify.Web.Tests.Model.Binding.Parsers;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Simplify.Web.Model.Validation.Attributes;

namespace Simplify.Web.Tests.Model.Binding.Parsers.ListToModelParserTestTypes;

public class TestModel
{
[Required]
public string? Prop1 { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Simplify.Web.Model.Binding.Attributes;

namespace Simplify.Web.Tests.TestEntities;
namespace Simplify.Web.Tests.Model.Binding.Parsers.ListToModelParserTestTypes;

public class TestModelDateTime
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Simplify.Web.Tests.Model.Binding.Parsers.ListToModelParserTestTypes;

public class TestModelStringsArray
{
public string[]? Prop1 { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace Simplify.Web.Tests.TestEntities;
namespace Simplify.Web.Tests.Model.Binding.Parsers.ListToModelParserTestTypes;

public class TestModelStringsList
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Simplify.Web.Tests.TestEntities;
namespace Simplify.Web.Tests.Model.Binding.Parsers.ListToModelParserTestTypes;

public class TestModelUndefinedType
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Simplify.Web.Model.Binding.Attributes;

namespace Simplify.Web.Tests.TestEntities;
namespace Simplify.Web.Tests.Model.Binding.Parsers.ListToModelParserTestTypes;

public class TestModelWithBindProperty
{
Expand Down
Loading

0 comments on commit 690f8cd

Please sign in to comment.