Skip to content

Commit

Permalink
Add test for DocumentModelFactory #237
Browse files Browse the repository at this point in the history
  • Loading branch information
Spacelord-XaN committed Feb 4, 2024
1 parent ec24910 commit fe55269
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 260 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,58 +24,48 @@ public void NoSellerThrowsInvalidOperationException()
public void NoStatusLink()
{
// Arrange
Settings.Acceptance.SignatureText = "Unterschrift";
Settings.Acceptance.SignatureText = "SignatureText";
Settings.Acceptance.StatusLinkFormat = null;

BasarEntity basar = Fixture.BuildBasar()
.With(basar => basar.Name, "4. Basar")
.With(basar => basar.Location, "Wasserau")
.With(basar => basar.Date, X.FirstContactDay)
.Create();
BasarEntity basar = Fixture.Create<BasarEntity>();
basar.Name = "4. Basar";
basar.Location = "Wasserau";
basar.Date = X.FirstContactDay;

SellerEntity seller = Fixture.BuildSeller()
.With(seller => seller.City, "Hobbingen")
.With(seller => seller.FirstName, "Hamfast")
.With(seller => seller.LastName, "Gamdschie")
.With(seller => seller.Street, "Beutelsend 4")
.With(seller => seller.ZIP, "A457857")
.Create();
SellerEntity seller = Fixture.Create<SellerEntity>();
seller.City = "Schlucht";
seller.FirstName = "Hamfast";
seller.LastName = "Gamdschie";
seller.Street = "Schwertgasse 4";
seller.ZIP = "A457857";

TransactionEntity acceptance = Fixture.BuildTransaction(basar)
.With(acceptance => acceptance.Seller, seller)
.With(acceptance => acceptance.TimeStamp, X.FirstContactDay.AddHours(2))
.Create();

ProductTypeEntity rennradType = Fixture.BuildProductType()
.With(type => type.Name, "Rennrad")
.Create();
ProductEntity rennrad = Fixture.BuildProduct()
.With(product => product.Id, 1)
.With(product => product.Brand, "Harlond Räder")
.With(product => product.Color, "blau")
.With(product => product.Description, "Mein tolles Rennrad")
.With(product => product.DonateIfNotSold, false)
.With(product => product.FrameNumber, "123456")
.With(product => product.Price, 12.34m)
.With(product => product.TireSize, "29")
.With(product => product.Type, rennradType)
.Create();
acceptance.Products.Add(new ProductToTransactionEntity { Product = rennrad, Transaction = acceptance });

ProductTypeEntity cityBikeType = Fixture.BuildProductType()
.With(type => type.Name, "City Bike")
.Create();
ProductEntity cityBike = Fixture.BuildProduct()
.With(product => product.Id, 2)
.With(product => product.Brand, "GCB")
.With(product => product.Color, "grün")
.With(product => product.Description, "Das schönste City Bike")
.With(product => product.DonateIfNotSold, true)
.With(product => product.FrameNumber, "XYZ")
.With(product => product.Price, 154.23m)
.With(product => product.TireSize, "28")
.With(product => product.Type, cityBikeType)
.Create();
ProductEntity racingBike = Fixture.Create<ProductEntity>();
racingBike.Id = 1;
racingBike.Brand = "Nicolai";
racingBike.Color = "Blue";
racingBike.Description = "Is very very old.";
racingBike.DonateIfNotSold = false;
racingBike.FrameNumber = "123456";
racingBike.Price = 12.34m;
racingBike.TireSize = "29";
racingBike.Type.Name = "Racing bike";
acceptance.Products.Add(new ProductToTransactionEntity { Product = racingBike, Transaction = acceptance });

ProductEntity cityBike = Fixture.Create<ProductEntity>();
cityBike.Id =2;
cityBike.Brand = "Wulfhorst";
cityBike.Color = "Green-Yellow";
cityBike.Description = "No brakes!";
cityBike.DonateIfNotSold = true;
cityBike.FrameNumber = "XYZ";
cityBike.Price = 154.23m;
cityBike.TireSize = "28";
cityBike.Type.Name = "City bike";
acceptance.Products.Add(new ProductToTransactionEntity { Product = cityBike, Transaction = acceptance });

// Act
Expand All @@ -89,16 +79,13 @@ public void NoStatusLink()
" - powered by https://github.com/braunau-mobil/velo-basar",
Settings.PageMargins,
Settings.Acceptance.SubTitle,
@"Hamfast Gamdschie
Beutelsend 4
A457857 Hobbingen
",
"Hamfast Gamdschie".Line("Schwertgasse 4").Line("A457857 Schlucht").Line(),
"VeloBasar_SellerIdShort_0",
false,
string.Empty,
Settings.Acceptance.TokenTitle,
seller.Token,
"Unterschrift ______________________________",
"SignatureText ______________________________",
"VeloBasar_AtLocationAndDateAndTime_Wasserau_05.04.2063 13:22:33",
Settings.QrCodeLengthMillimeters,
new ProductsTableDocumentModel(
Expand All @@ -112,8 +99,8 @@ A457857 Hobbingen
null,
new[]
{
new ProductTableRowDocumentModel("1", "Harlond Räder - Rennrad\r\nMein tolles Rennrad\r\n blau 123456", "29", "€ 12,34", null),
new ProductTableRowDocumentModel("2", "GCB - City Bike\r\nDas schönste City Bike\r\n grün XYZ\r\nVeloBasar_DonateIfNotSoldOnProductTable\r\n", "28", "€ 154,23", null),
new ProductTableRowDocumentModel("1", "Nicolai - Racing bike".Line("Is very very old.").Line(" Blue 123456"), "29", "€ 12,34", null),
new ProductTableRowDocumentModel("2", "Wulfhorst - City bike".Line("No brakes!").Line(" Green-Yellow XYZ").Line("VeloBasar_DonateIfNotSoldOnProductTable").Line(), "28", "€ 154,23", null),
}
)
);
Expand All @@ -124,59 +111,49 @@ A457857 Hobbingen
public void WithStatusLink()
{
// Arrange
Settings.Acceptance.SignatureText = "Unterschrift";
Settings.Acceptance.SignatureText = "SignatureText";
Settings.Acceptance.StatusLinkFormat = "StatusLinkFormat_{0}";

BasarEntity basar = Fixture.BuildBasar()
.With(basar => basar.Name, "4. Basar")
.With(basar => basar.Location, "Wasserau")
.With(basar => basar.Date, X.FirstContactDay)
.Create();
BasarEntity basar = Fixture.Create<BasarEntity>();
basar.Name = "4. Basar";
basar.Location = "Wasserau";
basar.Date = X.FirstContactDay;

SellerEntity seller = Fixture.BuildSeller()
.With(seller => seller.City, "Hobbingen")
.With(seller => seller.FirstName, "Hamfast")
.With(seller => seller.LastName, "Gamdschie")
.With(seller => seller.Street, "Beutelsend 4")
.With(seller => seller.ZIP, "A457857")
.With(seller => seller.Token, "X1234")
.Create();
SellerEntity seller = Fixture.Create<SellerEntity>();
seller.City = "Schlucht";
seller.FirstName = "Hamfast";
seller.LastName = "Gamdschie";
seller.Street = "Schwertgasse 4";
seller.Token = "X1234";
seller.ZIP = "A457857";

TransactionEntity acceptance = Fixture.BuildTransaction(basar)
.With(acceptance => acceptance.Seller, seller)
.With(acceptance => acceptance.TimeStamp, X.FirstContactDay.AddHours(2))
.Create();

ProductTypeEntity rennradType = Fixture.BuildProductType()
.With(type => type.Name, "Rennrad")
.Create();
ProductEntity rennrad = Fixture.BuildProduct()
.With(product => product.Id, 1)
.With(product => product.Brand, "Harlond Räder")
.With(product => product.Color, "blau")
.With(product => product.Description, "Mein tolles Rennrad")
.With(product => product.DonateIfNotSold, false)
.With(product => product.FrameNumber, "123456")
.With(product => product.Price, 12.34m)
.With(product => product.TireSize, "29")
.With(product => product.Type, rennradType)
.Create();
acceptance.Products.Add(new ProductToTransactionEntity { Product = rennrad, Transaction = acceptance });

ProductTypeEntity cityBikeType = Fixture.BuildProductType()
.With(type => type.Name, "City Bike")
.Create();
ProductEntity cityBike = Fixture.BuildProduct()
.With(product => product.Id, 2)
.With(product => product.Brand, "GCB")
.With(product => product.Color, "grün")
.With(product => product.Description, "Das schönste City Bike")
.With(product => product.DonateIfNotSold, true)
.With(product => product.FrameNumber, "XYZ")
.With(product => product.Price, 154.23m)
.With(product => product.TireSize, "28")
.With(product => product.Type, cityBikeType)
.Create();
ProductEntity racingBike = Fixture.Create<ProductEntity>();
racingBike.Id = 1;
racingBike.Brand = "Nicolai";
racingBike.Color = "Blue";
racingBike.Description = "Is very very old.";
racingBike.DonateIfNotSold = false;
racingBike.FrameNumber = "123456";
racingBike.Price = 12.34m;
racingBike.TireSize = "29";
racingBike.Type.Name = "Racing bike";
acceptance.Products.Add(new ProductToTransactionEntity { Product = racingBike, Transaction = acceptance });

ProductEntity cityBike = Fixture.Create<ProductEntity>();
cityBike.Id = 2;
cityBike.Brand = "Wulfhorst";
cityBike.Color = "Green-Yellow";
cityBike.Description = "No brakes!";
cityBike.DonateIfNotSold = true;
cityBike.FrameNumber = "XYZ";
cityBike.Price = 154.23m;
cityBike.TireSize = "28";
cityBike.Type.Name = "City bike";
acceptance.Products.Add(new ProductToTransactionEntity { Product = cityBike, Transaction = acceptance });

// Act
Expand All @@ -190,13 +167,13 @@ public void WithStatusLink()
" - powered by https://github.com/braunau-mobil/velo-basar",
Settings.PageMargins,
Settings.Acceptance.SubTitle,
"Hamfast Gamdschie\r\nBeutelsend 4\r\nA457857 Hobbingen\r\n",
"Hamfast Gamdschie".Line("Schwertgasse 4").Line("A457857 Schlucht").Line(""),
"VeloBasar_SellerIdShort_0",
true,
"StatusLinkFormat_X1234",
Settings.Acceptance.TokenTitle,
seller.Token,
"Unterschrift ______________________________",
"SignatureText ______________________________",
"VeloBasar_AtLocationAndDateAndTime_Wasserau_05.04.2063 13:22:33",
Settings.QrCodeLengthMillimeters,
new ProductsTableDocumentModel(
Expand All @@ -210,8 +187,8 @@ public void WithStatusLink()
null,
new[]
{
new ProductTableRowDocumentModel("1", "Harlond Räder - Rennrad\r\nMein tolles Rennrad\r\n blau 123456", "29", "€ 12,34", null),
new ProductTableRowDocumentModel("2", "GCB - City Bike\r\nDas schönste City Bike\r\n grün XYZ\r\nVeloBasar_DonateIfNotSoldOnProductTable\r\n", "28", "€ 154,23", null),
new ProductTableRowDocumentModel("1", "Nicolai - Racing bike".Line("Is very very old.").Line(" Blue 123456"), "29", "€ 12,34", null),
new ProductTableRowDocumentModel("2", "Wulfhorst - City bike".Line("No brakes!").Line(" Green-Yellow XYZ").Line("VeloBasar_DonateIfNotSoldOnProductTable").Line(), "28", "€ 154,23", null),
}
)
);
Expand Down
Loading

0 comments on commit fe55269

Please sign in to comment.