Ejemplo n.º 1
0
        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
            };
        }
Ejemplo n.º 2
0
        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");
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        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
            };
        }
Ejemplo n.º 6
0
        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>()));
        }
Ejemplo n.º 7
0
        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>());
        }
Ejemplo n.º 8
0
 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>());
 }
Ejemplo n.º 9
0
 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());
 }
Ejemplo n.º 10
0
        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>());
        }
Ejemplo n.º 11
0
        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());
        }
Ejemplo n.º 12
0
        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
            };
        }
Ejemplo n.º 13
0
        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));
        }
Ejemplo n.º 14
0
        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());
        }
Ejemplo n.º 15
0
        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>());
        }
Ejemplo n.º 16
0
        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));
        }
Ejemplo n.º 17
0
        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>());
        }
Ejemplo n.º 18
0
        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());
        }
Ejemplo n.º 19
0
        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));
        }
Ejemplo n.º 20
0
        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));
        }
Ejemplo n.º 21
0
        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));
        }
Ejemplo n.º 22
0
        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");
        }
Ejemplo n.º 23
0
        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));
        }
Ejemplo n.º 24
0
        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));
        }
Ejemplo n.º 25
0
        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));
        }
Ejemplo n.º 26
0
        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>);
        }
Ejemplo n.º 27
0
        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();
        }
Ejemplo n.º 28
0
        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>());
        }
Ejemplo n.º 29
0
        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();
        }
Ejemplo n.º 30
0
        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
            });
        }
Ejemplo n.º 31
0
        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
            });
        }
Ejemplo n.º 32
0
        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>());
        }
Ejemplo n.º 33
0
        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>()
            });
        }
Ejemplo n.º 34
0
        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
            });
        }
Ejemplo n.º 35
0
        /// <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;
                }
            }
        }
Ejemplo n.º 36
0
        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));
                    }
                }
            }
        }
Ejemplo n.º 37
0
        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));
        }