Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Task 1 - 1 #7

Merged
merged 5 commits into from
Apr 22, 2024
Merged
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,6 @@ FodyWeavers.xsd
.history/

# Built Visual Studio Code Extensions
*.vsix
*.vsix

test_results.txt
8 changes: 8 additions & 0 deletions Library/DataLayer/DataLayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

</Project>
37 changes: 0 additions & 37 deletions Library/DataLayer/Implementations/DataFillers/PresetFiller.cs

This file was deleted.

158 changes: 0 additions & 158 deletions Library/DataLayer/Implementations/DataFillers/RandomFiller.cs

This file was deleted.

8 changes: 8 additions & 0 deletions Library/LogicLayer/LogicLayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DataLayer\DataLayer.csproj" />
</ItemGroup>
Expand Down
48 changes: 2 additions & 46 deletions Library/Tests/DataLayerTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using DataLayer.Implementations;
using DataLayer.Implementations.Events;
using DataLayer.API;
using DataLayer.API;
using DataLayer.Implementations;

namespace Tests;

Expand Down Expand Up @@ -111,25 +110,6 @@ public void StateTests()
Assert.AreEqual(wholeStockPrice, bookProductState.Product.Price * bookProductState.Quantity);
}

[TestMethod]
public void BorrowEventTests()
{
// TODO: Implement BorrowEventTests

}

[TestMethod]
public void ReturnEventTests()
{
// TODO: Implement ReturnEventTests
}

[TestMethod]
public void DeliveryEventTests()
{
// TODO: Implement DeliveryEventTests
}

[TestMethod]
public void DataContextTests()
{
Expand Down Expand Up @@ -174,28 +154,4 @@ public void DataRepositoryTests()
Assert.IsFalse(dataRepository.GetAllProducts().Contains(product));
Assert.IsFalse(dataRepository.GetAllStates().Contains(state));
}

[TestMethod]
public void DataFillerTests()
{
IDataContext dataContext = new DataContext();
IDataFiller dataFiller = new PresetFiller();

dataFiller.Fill(dataContext);

Assert.AreEqual(5, dataContext.Users.Count);
Assert.AreEqual(5, dataContext.Products.Count);
Assert.AreEqual(5, dataContext.States.Count);
Assert.AreEqual(7, dataContext.Events.Count);

dataContext = new DataContext();
dataFiller = new RandomFiller();

dataFiller.Fill(dataContext);

Assert.IsTrue(dataContext.Users.Count >= 5 && dataContext.Users.Count <= 11);
Assert.IsTrue(dataContext.Products.Count >= 5 && dataContext.Products.Count <= 11);
Assert.AreEqual(dataContext.Products.Count, dataContext.States.Count);
Assert.IsTrue(dataContext.Events.Count >= 5 && dataContext.Events.Count <= 11);
}
}
33 changes: 33 additions & 0 deletions Library/Tests/FillerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using DataLayer.API;
using DataLayer.Implementations;

namespace Tests;

[TestClass]
public class FillerTests
{
[TestMethod]
public void PredefinedFillerTests()
{
IDataContext context = new DataContext();
IDataFiller filler = new PresetFiller();

filler.Fill(context);

Assert.AreEqual(5, context.Users.Count);
Assert.AreEqual(5, context.Products.Count);
Assert.AreEqual(5, context.States.Count);
Assert.AreEqual(11, context.Events.Count);
}

[TestMethod]
public void RandomFillerTests(){
IDataContext context = new DataContext();
IDataFiller filler = new RandomFiller();

filler.Fill(context);

Assert.ThrowsException<ArgumentException>(() => {RandomFiller.GetRandomNumber<int>(0);});
Assert.AreEqual(15, RandomFiller.GetRandomString(15).Length);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace DataLayer.API
using DataLayer.API;

namespace Tests
{
public interface IDataFiller
{
Expand Down
Loading