checktyle: delete unneeded imports, add TestFixture
This commit is contained in:
parent
df22a608d2
commit
ecce2c8cb9
@ -5,7 +5,7 @@ VisualStudioVersion = 17.12.35514.174
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SoftwareInstallationContracts", "SoftwareInstallationContracts\SoftwareInstallationContracts.csproj", "{B893E5AA-FB0B-4FFD-B918-87FB0CE540FC}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SoftwareInstallationTests", "..\SoftwareInstallationTests\SoftwareInstallationTests\SoftwareInstallationTests.csproj", "{7D2F4C92-7578-46BA-96C3-3B1B7E2B5340}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SoftwareInstallationTests", "..\SoftwareInstallationTests\SoftwareInstallationTests.csproj", "{7D2F4C92-7578-46BA-96C3-3B1B7E2B5340}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -1,12 +1,7 @@
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using System.Text.RegularExpressions;
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using SoftwareInstallationContracts.Extensions;
|
||||
using SoftwareInstallationContracts.Infrastucture;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.DataModels;
|
||||
|
||||
|
@ -1,13 +1,6 @@
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using SoftwareInstallationContracts.Extensions;
|
||||
using SoftwareInstallationContracts.Infrastucture;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.DataModels;
|
||||
|
||||
|
@ -1,12 +1,6 @@
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using SoftwareInstallationContracts.Extensions;
|
||||
using SoftwareInstallationContracts.Infrastucture;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.DataModels;
|
||||
|
||||
|
@ -1,11 +1,6 @@
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using SoftwareInstallationContracts.Extensions;
|
||||
using SoftwareInstallationContracts.Infrastucture;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.DataModels;
|
||||
|
||||
|
@ -2,11 +2,6 @@
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using SoftwareInstallationContracts.Extensions;
|
||||
using SoftwareInstallationContracts.Infrastucture;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.DataModels;
|
||||
|
||||
|
@ -1,11 +1,6 @@
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using SoftwareInstallationContracts.Extensions;
|
||||
using SoftwareInstallationContracts.Infrastucture;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.DataModels;
|
||||
|
||||
|
@ -2,16 +2,11 @@
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using SoftwareInstallationContracts.Extensions;
|
||||
using SoftwareInstallationContracts.Infrastucture;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.DataModels;
|
||||
|
||||
public class SoftwareDataModel(string id, string softwareName, SoftwareType softwareType,
|
||||
string companyId, double price, bool isDeleted) : IValidation
|
||||
string companyId, double price, bool isDeleted, List<SoftwareWarehouseDataModel> warehouses) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
|
||||
@ -25,6 +20,8 @@ public class SoftwareDataModel(string id, string softwareName, SoftwareType soft
|
||||
|
||||
public bool IsDeleted { get; private set; } = isDeleted;
|
||||
|
||||
public List<SoftwareWarehouseDataModel> Warehouses { get; private set; } = warehouses;
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (Id.isEmpty())
|
||||
@ -47,5 +44,8 @@ public class SoftwareDataModel(string id, string softwareName, SoftwareType soft
|
||||
|
||||
if (Price <= 0)
|
||||
throw new ValidationFieldException("Field Price is less than or equal to 0");
|
||||
|
||||
if ((Warehouses?.Count() ?? 0) == 0)
|
||||
throw new ValidationFieldException("The software must include warehouses");
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,6 @@
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using SoftwareInstallationContracts.Extensions;
|
||||
using SoftwareInstallationContracts.Infrastucture;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.DataModels;
|
||||
|
||||
|
@ -1,11 +1,6 @@
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using SoftwareInstallationContracts.Extensions;
|
||||
using SoftwareInstallationContracts.Infrastucture;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.DataModels;
|
||||
|
||||
|
@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using SoftwareInstallationContracts.Extensions;
|
||||
using SoftwareInstallationContracts.Infrastucture;
|
||||
|
||||
|
@ -1,12 +1,6 @@
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using SoftwareInstallationContracts.Extensions;
|
||||
using SoftwareInstallationContracts.Infrastucture;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.DataModels;
|
||||
|
||||
|
@ -1,21 +1,14 @@
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using SoftwareInstallationContracts.Extensions;
|
||||
using SoftwareInstallationContracts.Infrastucture;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.DataModels;
|
||||
|
||||
public class WarehouseDataModel(string id, int minCount, int currentCount, DateTime date) : IValidation
|
||||
public class WarehouseDataModel(string id, int totalCount, DateTime date) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
|
||||
public int MinCount { get; private set; } = minCount;
|
||||
|
||||
public int CurrentCount { get; private set; } = currentCount;
|
||||
public int TotalCount { get; private set; } = totalCount;
|
||||
|
||||
public DateTime ChangeDate { get; private set; } = date;
|
||||
|
||||
@ -27,13 +20,7 @@ public class WarehouseDataModel(string id, int minCount, int currentCount, DateT
|
||||
if (!Id.isGuid())
|
||||
throw new ValidationFieldException("The value in the field Id is not a unique identifier");
|
||||
|
||||
if (MinCount <= 0)
|
||||
throw new ValidationFieldException("Field MinCount is less than or equal to 0");
|
||||
|
||||
if (CurrentCount <= 0)
|
||||
throw new ValidationFieldException("Field CurrentCount is less than or equal to 0");
|
||||
|
||||
if (CurrentCount < MinCount)
|
||||
throw new ValidationFieldException("Field CurrentCount is less than MinCount");
|
||||
if (TotalCount <= 0)
|
||||
throw new ValidationFieldException("Field TotalCount is less than or equal to 0");
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,6 @@
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using SoftwareInstallationContracts.Extensions;
|
||||
using SoftwareInstallationContracts.Infrastucture;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.DataModels;
|
||||
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.Enums;
|
||||
namespace SoftwareInstallationContracts.Enums;
|
||||
|
||||
public enum PostType
|
||||
{
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.Enums;
|
||||
namespace SoftwareInstallationContracts.Enums;
|
||||
|
||||
public enum SoftwareType
|
||||
{
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.Exceptions;
|
||||
namespace SoftwareInstallationContracts.Exceptions;
|
||||
|
||||
public class ValidationFieldException(String message) : Exception(message)
|
||||
{
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.Extensions;
|
||||
namespace SoftwareInstallationContracts.Extensions;
|
||||
|
||||
public static class StringExceptions
|
||||
{
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationContracts.Infrastucture;
|
||||
namespace SoftwareInstallationContracts.Infrastucture;
|
||||
|
||||
public interface IValidation
|
||||
{
|
||||
|
@ -1,10 +1,5 @@
|
||||
using SoftwareInstallationContracts.DataModels;
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationTests.DataModelsTests;
|
||||
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SoftwareInstallationContracts.DataModels;
|
||||
using SoftwareInstallationContracts.DataModels;
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
|
||||
namespace SoftwareInstallationTests.DataModelsTests;
|
||||
|
@ -1,10 +1,5 @@
|
||||
using SoftwareInstallationContracts.DataModels;
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationTests.DataModelsTests;
|
||||
|
||||
|
@ -1,11 +1,5 @@
|
||||
using SoftwareInstallationContracts.DataModels;
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationTests.DataModelsTests;
|
||||
|
||||
|
@ -1,11 +1,6 @@
|
||||
using SoftwareInstallationContracts.DataModels;
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using SoftwareInstallationContracts.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
|
||||
namespace SoftwareInstallationTests.DataModelsTests;
|
||||
|
||||
|
@ -1,11 +1,5 @@
|
||||
using SoftwareInstallationContracts.DataModels;
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationTests.DataModelsTests;
|
||||
|
||||
|
@ -1,12 +1,6 @@
|
||||
using SoftwareInstallationContracts.DataModels;
|
||||
using SoftwareInstallationContracts.Enums;
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static NUnit.Framework.Internal.OSPlatform;
|
||||
|
||||
namespace SoftwareInstallationTests.DataModelsTests;
|
||||
|
||||
@ -83,6 +77,15 @@ internal class SoftwareDataModelTests
|
||||
Assert.That(() => software.Validate(), Throws.TypeOf<ValidationFieldException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SoftwaresIsNullOrEmptyTest()
|
||||
{
|
||||
software = CreateDataModel(Guid.NewGuid().ToString(), "name", SoftwareType.ApplicationSoftware, Guid.NewGuid().ToString(), 10, false, null);
|
||||
Assert.That(() => software.Validate(), Throws.TypeOf<ValidationFieldException>());
|
||||
software = CreateDataModel(Guid.NewGuid().ToString(), "name", SoftwareType.ApplicationSoftware, Guid.NewGuid().ToString(), 10, false, []);
|
||||
Assert.That(() => software.Validate(), Throws.TypeOf<ValidationFieldException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllFieldsIsCorrectTest()
|
||||
{
|
||||
|
@ -1,11 +1,5 @@
|
||||
using SoftwareInstallationContracts.DataModels;
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using SoftwareInstallationContracts.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationTests.DataModelsTests;
|
||||
|
||||
|
@ -1,10 +1,5 @@
|
||||
using SoftwareInstallationContracts.DataModels;
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationTests.DataModelsTests;
|
||||
|
||||
|
@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SoftwareInstallationContracts.DataModels;
|
||||
using SoftwareInstallationContracts.DataModels;
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
|
||||
namespace SoftwareInstallationTests.DataModelsTests;
|
||||
|
@ -1,10 +1,5 @@
|
||||
using SoftwareInstallationContracts.DataModels;
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationTests.DataModelsTests;
|
||||
|
||||
|
@ -1,10 +1,5 @@
|
||||
using SoftwareInstallationContracts.DataModels;
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationTests.DataModelsTests;
|
||||
|
||||
@ -43,8 +38,8 @@ internal class WarehouseDataModelTests
|
||||
{
|
||||
string warehouseId = Guid.NewGuid().ToString();
|
||||
int totalCount = 10;
|
||||
DateTime date = DateTime.UtcNow;
|
||||
WarehouseDataModel warehouse = CreateDataModel(warehouseId, totalCount, date);
|
||||
DateTime date = DateTime.UtcNow;
|
||||
warehouse = CreateDataModel(warehouseId, totalCount, date);
|
||||
Assert.That(() => warehouse.Validate(), Throws.Nothing);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
|
@ -1,11 +1,5 @@
|
||||
using SoftwareInstallationContracts.DataModels;
|
||||
using SoftwareInstallationContracts.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SoftwareInstallationTests.DataModelsTests;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user