public EditShould() { fixture = new SetupFixture(); sut = new AppointmentController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object ); fixture.repositoryWrapper .Setup(x => x.Appointment.GetAppointmentByIdAsync(It.IsAny <int>())) .ReturnsAsync(new Appointment()); fixture.repositoryWrapper .Setup(x => x.Listing.GetAllListingsAsync()) .ReturnsAsync(new List <Listing>()); fixture.repositoryWrapper .Setup(x => x.Listing.GetAllListingsAsync()) .ReturnsAsync(new List <Listing>()); fixture.mapper.Setup(x => x.Map <EditAppointmentManagementDTO>(It.IsAny <Appointment>())) .Returns(new EditAppointmentManagementDTO()); app = new EditAppointmentManagementDTO() { Id = 1 }; }
public CreateShould() { fixture = new SetupFixture(); env = new Mock <IHostEnvironment>(); imageUploadWrapper = new Mock <IImageUploadWrapper>(); env.Setup(m => m.EnvironmentName).Returns("Hosting:UnitTestEnvironment"); sut = new PhotoController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object, env.Object, imageUploadWrapper.Object); photo = new Photo() { Id = 1, ImageLink = "dgfdfgdf" }; photoDTO = new PhotoDTO() { Id = 1, ImageLink = string.Empty, File = It.IsAny <IFormFile>() }; fixture.repositoryWrapper .Setup(x => x.Photo.GetPhotoByIdAsync(It.IsAny <int>())) .ReturnsAsync(It.IsAny <Photo>); fixture.repositoryWrapper.Setup(x => x.Photo.GetAllPhotosAsync()).ReturnsAsync(new List <Photo>() { photo }); fixture.mapper.Setup(x => x.Map <PhotoDTO>(It.IsAny <Photo>())).Returns(new PhotoDTO()); imageUploadWrapper.Setup(x => x.Upload(It.IsAny <IFormFile>(), It.IsAny <IHostEnvironment>())) .Returns("imageurl"); }
public CreateShould() { fixture = new SetupFixture(); sut = new AppointmentController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object ); fixture.repositoryWrapper .Setup(x => x.Employee.GetUserId(new ClaimsPrincipal())) .ReturnsAsync(string.Empty); fixture.repositoryWrapper .Setup(x => x.Appointment.GetAppointmentByIdAsync(It.IsAny <int>())) .ReturnsAsync(new Appointment()); fixture.repositoryWrapper .Setup(x => x.Listing.GetAllListingsAsync()) .ReturnsAsync(new List <Listing>()); fixture.mapper.Setup(x => x.Map <CreateAppointmentDTO>(It.IsAny <Appointment>())) .Returns(new CreateAppointmentDTO()); }
public void PersistingAListOfProductsAndCategories() { var builderSetup = new SetupFixture().SetUp(); Database.Clear(); const int numProducts = 500; const int numCategories = 50; const int numCategoriesForEachProduct = 5; var categories = new Builder <Category>(builderSetup).CreateListOfSize(numCategories).Persist(); new Builder <Product>(builderSetup) .CreateListOfSize(numProducts) .All() .With(x => x.Categories = Pick <Category> .UniqueRandomList(With.Exactly(numCategoriesForEachProduct).Elements).From(categories)) .Persist(); // NB: Persistence is setup in the SetupFixture class DataTable productsTable = Database.GetContentsOf(Database.Tables.Product); DataTable categoriesTable = Database.GetContentsOf(Database.Tables.Category); DataTable productCategoriesTable = Database.GetContentsOf(Database.Tables.ProductCategory); Assert.That(productsTable.Rows.Count, Is.EqualTo(numProducts)); Assert.That(categoriesTable.Rows.Count, Is.EqualTo(numCategories)); Assert.That(productCategoriesTable.Rows.Count, Is.EqualTo(numCategoriesForEachProduct * numProducts)); }
public EditShould() { fixture = new SetupFixture(); env = new Mock <IHostEnvironment>(); imageUploadWrapper = new Mock <IImageUploadWrapper>(); imageUploadWrapper.Setup(x => x.Upload(It.IsAny <IFormFile>(), It.IsAny <IHostEnvironment>())) .Returns("imageurl"); env.Setup(m => m.EnvironmentName).Returns("Hosting:UnitTestEnvironment"); sut = new EventController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object, env.Object, imageUploadWrapper.Object); fixture.repositoryWrapper.Setup(x => x.Event.GetEventByIdAsync(It.IsAny <int>())).ReturnsAsync(new Event()); fixture.mapper.Setup(x => x.Map <EventManagementDTO>(It.IsAny <Event>())).Returns(new EventManagementDTO()).Verifiable(); eve = new EventManagementDTO() { Id = 1 }; }
public ContactShould() { fixture = new SetupFixture(); sut = new HomeController(fixture.Logger.Object, fixture.mapper.Object, fixture.repositoryWrapper.Object); fixture.repositoryWrapper.Setup(h => h.Ticket.CreateTicket(It.IsAny <Ticket>())); }
public AboutShould() { fixture = new SetupFixture(); sut = new HomeController(fixture.Logger.Object, fixture.mapper.Object, fixture.repositoryWrapper.Object); fixture.repositoryWrapper.Setup(x => x.Employee.GetAllStaffAsync()).ReturnsAsync(It.IsAny <List <ApplicationUser> >()); fixture.mapper.Setup(x => x.Map <List <UserDTO> >(It.IsAny <List <UserDTO> >())).Returns(new List <UserDTO>()); }
public IndexShould() { fixture = new SetupFixture(); fixture.context.Setup(_ => _.Set <Service>()).Returns(new Mock <DbSet <Service> >().Object); sut = new ServiceController(fixture.Logger.Object, fixture.mapper.Object, fixture.repositoryWrapper.Object); fixture.repositoryWrapper.Setup(x => x.Service.GetAllServicesAsync()).ReturnsAsync(new List <Service>() { It.IsAny <Service>() }); fixture.mapper.Setup(x => x.Map <List <ServiceDTO> >(It.IsAny <List <Service> >())).Returns(new List <ServiceDTO>()); }
public CreateShould() { fixture = new SetupFixture(); AddressDTO = new AddressDTO() { Number = "1", FirstLine = "FirstLine", SecondLine = "SecondLine" }; sut = new AddressController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object); fixture.repositoryWrapper.Setup(x => x.Address.Create(It.IsAny <Address>())).Verifiable(); fixture.mapper.Setup(x => x.Map <AddressDTO>(It.IsAny <Address>())).Returns(new AddressDTO()); }
public IndexShould() { fixture = new SetupFixture(); sut = new EventController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object); fixture.repositoryWrapper.Setup(x => x.Event.GetAllEventsAsync()).ReturnsAsync(new List <Event>() { It.IsAny <Event>() }); fixture.mapper.Setup(x => x.Map <List <EventDTO> >(It.IsAny <List <Event> >())).Returns(new List <EventDTO>()); }
public EditShould() { fixture = new SetupFixture(); sut = new TicketController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object); fixture.repositoryWrapper .Setup(x => x.Ticket.GetTicketByIdAsync(It.IsAny <string>())) .ReturnsAsync(new Ticket()); fixture.mapper.Setup(x => x.Map <TicketManagementDTO>(It.IsAny <Ticket>())) .Returns(new TicketManagementDTO()); }
public EditShould() { fixture = new SetupFixture(); env = new Mock <IHostEnvironment>(); imageUploadWrapper = new Mock <IImageUploadWrapper>(); env.Setup(m => m.EnvironmentName).Returns("Hosting:UnitTestEnvironment"); sut = new ListingController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object, env.Object, imageUploadWrapper.Object); address = new Address() { FirstLine = "TestFirstLine", Number = "23", TownCity = "TestCity", Postcode = "Xf343xs", Id = 1 }; address2 = new Address() { FirstLine = "FirstLine", Number = "33", TownCity = "TestCity", Postcode = "Xf343xs", Id = 1 }; fixture.repositoryWrapper .Setup(x => x.Listing.GetListingByIdAsync(It.IsAny <int>())) .ReturnsAsync(It.IsAny <Listing>); fixture.repositoryWrapper.Setup(x => x.Address.GetAllAddressesNotInUseAsync()).ReturnsAsync(new List <Address>() { address }); fixture.repositoryWrapper.Setup(x => x.Address.GetAddressByIdAsync(It.IsAny <int>())).ReturnsAsync(address2); fixture.mapper.Setup(x => x.Map <ListingManagementDTO>(It.IsAny <Listing>())).Returns(new ListingManagementDTO() { Address = address }); imageUploadWrapper.Setup(x => x.Upload(It.IsAny <IFormFile>(), It.IsAny <IHostEnvironment>())) .Returns("imageurl"); fixture.mapper.Setup(x => x.Map <Listing>(It.IsAny <ListingManagementDTO>())).Returns(new Listing() { Id = 1 }); listingManagementDTO = new ListingManagementDTO() { Id = 1, Address = new Address() { Id = 1 }, File = new Mock <IFormFile>().Object }; }
public void PersistingASingleTaxTypeAndAListOf100Products() { var builderSetup = new SetupFixture().SetUp(); Database.Clear(); var taxType = new Builder<TaxType>(builderSetup).CreateNew().Persist(); new Builder<Product>(builderSetup).CreateListOfSize(100) .All() .With(x => x.TaxType = taxType) .Persist(); // NB: Persistence is setup in the SetupFixture class var dbProducts = Database.GetContentsOf(Database.Tables.Product); Assert.That(dbProducts.Rows.Count, Is.EqualTo(100)); }
public CreateShould() { fixture = new SetupFixture(); sut = new ServiceController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object); fixture.repositoryWrapper .Setup(x => x.Service.GetServiceByIdAsync(It.IsAny <int>())) .ReturnsAsync(new Service()); fixture.mapper.Setup(x => x.Map <ServiceDTO>(It.IsAny <Service>())) .Returns(new ServiceDTO()); }
public DetailsShould() { fixture = new SetupFixture(); sut = new ListingController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object); fixture.repositoryWrapper.Setup(x => x.Listing.GetAllListingsAsync()).ReturnsAsync(new List <Listing>() { It.IsAny <Listing>() }); fixture.mapper.Setup(x => x.Map <ListingDetailDTO>(It.IsAny <Listing>())).Returns(new ListingDetailDTO()); fixture.mapper.Setup(x => x.Map <List <ExtendedListingDTO> >(It.IsAny <List <Listing> >())).Returns(new List <ExtendedListingDTO>()); }
public void PersistingASingleObject() { var builderSetup =new SetupFixture().SetUp(); Database.Clear(); new Builder<Product>(builderSetup).CreateNew().Persist(); // Go directly to the database to do some asserts var dataTable = Database.GetContentsOf(Database.Tables.Product); Assert.That(dataTable.Rows.Count, Is.EqualTo(1)); Assert.That(dataTable.Rows[0]["Title"], Is.EqualTo("Title1")); Assert.That(dataTable.Rows[0]["Description"], Is.EqualTo("Description1")); Assert.That(dataTable.Rows[0]["PriceBeforeTax"], Is.EqualTo(1m)); Assert.That(dataTable.Rows[0]["QuantityInStock"], Is.EqualTo(1)); }
public IndexShould() { fixture = new SetupFixture(); sut = new AddressController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object); fixture.repositoryWrapper .Setup(x => x.Address.GetAllAddressesAsync()) .ReturnsAsync(new List <Address>() { It.IsAny <Address>() }); fixture.mapper.Setup(x => x.Map <List <AddressDTO> >(It.IsAny <List <Address> >())).Returns(new List <AddressDTO>()); }
public EditShould() { fixture = new SetupFixture(); sut = new AddressController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object); Address = new Address() { Id = 1, FirstLine = "FirstLine", SecondLine = "SecondLine" }; fixture.repositoryWrapper.Setup(x => x.Address.GetAddressByIdAsync(It.IsAny <int>())).ReturnsAsync(Address); fixture.mapper.Setup(x => x.Map <AddressDTO>(It.IsAny <Address>())).Returns(new AddressDTO()); }
public void PersistingUsingPick_UpTo_AndDoForEach() { var builderSetup = new SetupFixture().SetUp(); Database.Clear(); var categories = new Builder<Category>(builderSetup).CreateListOfSize(10).Persist(); new Builder<Product>(builderSetup) .CreateListOfSize(50) .All() .DoForEach((x, y) => x.AddToCategory(y), Pick<Category>.UniqueRandomList(With.UpTo(4).Elements).From(categories)) .Persist(); DataTable productCategoriesTable = Database.GetContentsOf(Database.Tables.ProductCategory); Assert.That(productCategoriesTable.Rows.Count, Is.LessThanOrEqualTo(50 * 4)); }
public void PersistingASingleTaxTypeAndAListOf100Products() { var builderSetup = new SetupFixture().SetUp(); Database.Clear(); var taxType = new Builder <TaxType>(builderSetup).CreateNew().Persist(); new Builder <Product>(builderSetup).CreateListOfSize(100) .All() .With(x => x.TaxType = taxType) .Persist(); // NB: Persistence is setup in the SetupFixture class var dbProducts = Database.GetContentsOf(Database.Tables.Product); Assert.That(dbProducts.Rows.Count, Is.EqualTo(100)); }
public void PersistingASingleObject() { var builderSetup = new SetupFixture().SetUp(); Database.Clear(); new Builder <Product>(builderSetup).CreateNew().Persist(); // Go directly to the database to do some asserts var dataTable = Database.GetContentsOf(Database.Tables.Product); Assert.That(dataTable.Rows.Count, Is.EqualTo(1)); Assert.That(dataTable.Rows[0]["Title"], Is.EqualTo("Title1")); Assert.That(dataTable.Rows[0]["Description"], Is.EqualTo("Description1")); Assert.That(dataTable.Rows[0]["PriceBeforeTax"], Is.EqualTo(1m)); Assert.That(dataTable.Rows[0]["QuantityInStock"], Is.EqualTo(1)); }
public IndexShould() { fixture = new SetupFixture(); env = new Mock <IHostEnvironment>(); imageUploadWrapper = new Mock <IImageUploadWrapper>(); env.Setup(m => m.EnvironmentName).Returns("Hosting:UnitTestEnvironment"); sut = new ListingController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object, env.Object, imageUploadWrapper.Object); fixture.repositoryWrapper.Setup(x => x.Listing.GetAllListingsAsync()).ReturnsAsync(It.IsAny <List <Listing> >()); fixture.mapper.Setup(x => x.Map <List <ListingManagementDTO> >(It.IsAny <Listing>())).Returns(new List <ListingManagementDTO>()); imageUploadWrapper.Setup(x => x.Upload(It.IsAny <IFormFile>(), It.IsAny <IHostEnvironment>())) .Returns("imageUrl"); }
public void PersistingUsingPick_UpTo_AndDoForEach() { var builderSetup = new SetupFixture().SetUp(); Database.Clear(); var categories = new Builder <Category>(builderSetup).CreateListOfSize(10).Persist(); new Builder <Product>(builderSetup) .CreateListOfSize(50) .All() .DoForEach((x, y) => x.AddToCategory(y), Pick <Category> .UniqueRandomList(With.UpTo(4).Elements).From(categories)) .Persist(); DataTable productCategoriesTable = Database.GetContentsOf(Database.Tables.ProductCategory); Assert.That(productCategoriesTable.Rows.Count, Is.LessThanOrEqualTo(50 * 4)); }
public void AddingACustom_With_ExtensionForProducts() { BuilderSetup builderSetup = new SetupFixture().DoSetup(); var products = new Builder <Product>(builderSetup) .CreateListOfSize(10) .All() .WithWarehouseLocations() // This will only appear when using Builder<Product> .Build(); Assert.That(products[0].Location.Aisle, Is.EqualTo('A')); Assert.That(products[0].Location.Shelf, Is.EqualTo(1)); Assert.That(products[0].Location.Location, Is.EqualTo(7500)); Assert.That(products[9].Location.Aisle, Is.EqualTo('J')); Assert.That(products[9].Location.Shelf, Is.EqualTo(10)); Assert.That(products[9].Location.Location, Is.EqualTo(16500)); }
public void AddingACustom_With_ExtensionForProducts() { BuilderSetup builderSetup = new SetupFixture().DoSetup(); var products = new Builder<Product>(builderSetup) .CreateListOfSize(10) .All() .WithWarehouseLocations() // This will only appear when using Builder<Product> .Build(); Assert.That(products[0].Location.Aisle, Is.EqualTo('A')); Assert.That(products[0].Location.Shelf, Is.EqualTo(1)); Assert.That(products[0].Location.Location, Is.EqualTo(7500)); Assert.That(products[9].Location.Aisle, Is.EqualTo('J')); Assert.That(products[9].Location.Shelf, Is.EqualTo(10)); Assert.That(products[9].Location.Location, Is.EqualTo(16500)); }
public IndexShould() { fixture = new SetupFixture(); sut = new HomeController(fixture.Logger.Object, fixture.mapper.Object, fixture.repositoryWrapper.Object ); fixture.repositoryWrapper.Setup(x => x.Service.GetAllServicesAsync()).ReturnsAsync(new List <Service>() { It.IsAny <Service>() }); fixture.repositoryWrapper.Setup(x => x.Listing.GetAllListingsAsync()).ReturnsAsync(new List <Listing>() { It.IsAny <Listing>() }); fixture.repositoryWrapper.Setup(x => x.Event.GetActiveEventAsync()).ReturnsAsync(It.IsAny <Event>); }
public void SpecifyingACustomPropertyNamerForASpecificType() { BuilderSetup builderSetup = new SetupFixture().DoSetup(); builderSetup.SetPropertyNamerFor<Product>(new CustomProductPropertyNamer(new ReflectionUtil(),builderSetup)); var products = new Builder<Product>(builderSetup).CreateListOfSize(10).Build(); Assert.That(products[0].Location.Aisle, Is.EqualTo('A')); Assert.That(products[0].Location.Shelf, Is.EqualTo(2)); Assert.That(products[0].Location.Location, Is.EqualTo(1000)); Assert.That(products[9].Location.Aisle, Is.EqualTo('J')); Assert.That(products[9].Location.Shelf, Is.EqualTo(20)); Assert.That(products[9].Location.Location, Is.EqualTo(10000)); // Reset it afterwards so the other tests work as expected builderSetup.ResetToDefaults(); }
public IndexShould() { fixture = new SetupFixture(); sut = new AgentDashboardController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object ); fixture.repositoryWrapper .Setup(x => x.Employee.GetUserId(new ClaimsPrincipal())) .ReturnsAsync(string.Empty); fixture.repositoryWrapper .Setup(x => x.Appointment.GetAllAppointmentsByStaffIdAsync(It.IsAny <string>())) .ReturnsAsync(new List <Appointment>() { It.IsAny <Appointment>() }); fixture.mapper.Setup(x => x.Map <List <AppointmentDTO> >(It.IsAny <List <Appointment> >())).Returns(new List <AppointmentDTO>()); }
public void SpecifyingACustomPropertyNamerForASpecificType() { BuilderSetup builderSetup = new SetupFixture().DoSetup(); builderSetup.SetPropertyNamerFor <Product>(new CustomProductPropertyNamer(new ReflectionUtil(), builderSetup)); var products = new Builder <Product>(builderSetup).CreateListOfSize(10).Build(); Assert.That(products[0].Location.Aisle, Is.EqualTo('A')); Assert.That(products[0].Location.Shelf, Is.EqualTo(2)); Assert.That(products[0].Location.Location, Is.EqualTo(1000)); Assert.That(products[9].Location.Aisle, Is.EqualTo('J')); Assert.That(products[9].Location.Shelf, Is.EqualTo(20)); Assert.That(products[9].Location.Location, Is.EqualTo(10000)); // Reset it afterwards so the other tests work as expected builderSetup.ResetToDefaults(); }
public DeleteShould() { fixture = new SetupFixture(); sut = new BuyerController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object); fixture.repositoryWrapper .Setup(x => x.Buyer.GetBuyerByIdAsync(It.IsAny <int>())).ReturnsAsync(new Buyer() { Id = 1 }); fixture.mapper.Setup(x => x.Map <BuyerManagementDTO>(It.IsAny <Buyer>())). Returns(new BuyerManagementDTO() { Id = 1 }); }
public EditShould() { fixture = new SetupFixture(); sut = new SaleController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object); fixture.repositoryWrapper .Setup(x => x.Sale.GetSaleByIdAsync(It.IsAny <int>())).ReturnsAsync(new Sale() { Id = 1 }); fixture.repositoryWrapper .Setup(x => x.Listing.GetListingsIdByAddressID(It.IsAny <int>())).Returns(new Listing() { Id = 1 }); fixture.repositoryWrapper .Setup(x => x.Address.GetAllAddressesAsync()).ReturnsAsync(new List <Address>() { new Address() { Id = 1, Number = "23", FirstLine = "test" } }); fixture.repositoryWrapper .Setup(x => x.Employee.GetUserId(new ClaimsPrincipal())) .ReturnsAsync("A test"); fixture.mapper.Setup(x => x.Map <SaleManagementDTO>(It.IsAny <Sale>())). Returns(new SaleManagementDTO() { Id = 1 }); }
public IndexShould() { fixture = new SetupFixture(); env = new Mock <IHostEnvironment>(); imageUploadWrapper = new Mock <IImageUploadWrapper>(); env.Setup(m => m.EnvironmentName).Returns("Hosting:UnitTestEnvironment"); sut = new EventController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object, env.Object, imageUploadWrapper.Object); fixture.repositoryWrapper .Setup(x => x.Event.GetAllEventsAsync()) .ReturnsAsync(new List <Event>() { It.IsAny <Event>() }); fixture.mapper.Setup(x => x.Map <List <EventManagementDTO> >(It.IsAny <List <Event> >())). Returns(new List <EventManagementDTO>()); }
public IndexShould() { fixture = new SetupFixture(); sut = new SaleController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object); fixture.repositoryWrapper .Setup(x => x.Sale.GetAllSalesAsync()) .ReturnsAsync(new List <Sale>() { It.IsAny <Sale>() }); fixture.mapper.Setup(x => x.Map <List <SaleManagementDTO> >(It.IsAny <List <Sale> >())). Returns(new List <SaleManagementDTO>() { It.IsAny <SaleManagementDTO>() }); }
public DetailsShould() { fixture = new SetupFixture(); sut = new SaleController(fixture.Logger.Object, fixture.repositoryWrapper.Object, fixture.mapper.Object); fixture.repositoryWrapper .Setup(x => x.Sale.GetSaleByIdAsync(It.IsAny <int>())) .ReturnsAsync(new Sale() { Id = 1 }); fixture.mapper.Setup(x => x.Map <SaleManagementDTO>(It.IsAny <Sale>())). Returns(new SaleManagementDTO() { Id = 1 }); }
/// <summary> /// The main. /// </summary> private static void Main() { var setupFixture = new SetupFixture(); setupFixture.Setup(); while (true) { Console.WriteLine("1 - Tcp"); Console.WriteLine("2 - Tcp performance tests #2"); Console.WriteLine("3 - Tcp performance tests"); Console.WriteLine("4 - Tcp s2s performance tests"); Console.WriteLine(); Console.WriteLine("Q - Quit"); ConsoleKeyInfo keyInfo = Console.ReadKey(true); switch (keyInfo.Key) { case ConsoleKey.D1: RunTcpClientTests(); break; case ConsoleKey.D2: RunTcpPerformanceTests(2); break; case ConsoleKey.D3: RunTcpPerformanceTests(1); break; case ConsoleKey.D4: RunS2sPerformanceTests(); break; case ConsoleKey.Q: return; } } }
public void CreatingAHierarchyOfCategories() { var builderSetup = new SetupFixture().SetUp(); const int depth = 3; const int minChildren = 3; const int maxChildren = 8; var hierarchySpec = new Builder<HierarchySpec<Category>>(builderSetup).CreateNew() .With(x => x.AddMethod = (y, z) => y.AddChild(z)) .With(x => x.Depth = depth) .With(x => x.MinimumChildren = minChildren) .With(x => x.MaximumChildren = maxChildren) .With(x => x.NamingMethod = (y, z) => y.Title = "Category " + z) .With(x => x.NumberOfRoots = 5) .Build(); var categories = new Builder<Category>(builderSetup).CreateListOfSize(10000) .All() .PersistHierarchy(hierarchySpec); foreach (var root in categories) { Assert.That(root.Children.Count, Is.AtLeast(minChildren)); Assert.That(root.Children.Count, Is.AtMost(maxChildren)); foreach (var child1 in root.Children) { Assert.That(child1.Children.Count, Is.AtLeast(minChildren)); Assert.That(child1.Children.Count, Is.AtMost(maxChildren)); foreach (var child2 in child1.Children) { Assert.That(child2.Children.Count, Is.AtLeast(minChildren)); Assert.That(child2.Children.Count, Is.AtMost(maxChildren)); } } } }
public void PersistingAListOfProductsAndCategories() { var builderSetup = new SetupFixture().SetUp(); Database.Clear(); const int numProducts = 500; const int numCategories = 50; const int numCategoriesForEachProduct = 5; var categories = new Builder<Category>(builderSetup).CreateListOfSize(numCategories).Persist(); new Builder<Product>(builderSetup) .CreateListOfSize(numProducts) .All() .With(x => x.Categories = Pick<Category>.UniqueRandomList(With.Exactly(numCategoriesForEachProduct).Elements).From(categories)) .Persist(); // NB: Persistence is setup in the SetupFixture class DataTable productsTable = Database.GetContentsOf(Database.Tables.Product); DataTable categoriesTable = Database.GetContentsOf(Database.Tables.Category); DataTable productCategoriesTable = Database.GetContentsOf(Database.Tables.ProductCategory); Assert.That(productsTable.Rows.Count, Is.EqualTo(numProducts)); Assert.That(categoriesTable.Rows.Count, Is.EqualTo(numCategories)); Assert.That(productCategoriesTable.Rows.Count, Is.EqualTo(numCategoriesForEachProduct * numProducts)); }