示例#1
0
 public void FilterByPriceWithOnlyMinShouldReturnItemsWithDesiredPrice()
 {
     Assert.Collection(
         Menu.FilterByPrice(Menu.CompleteMenu(), 7, null),
         (rr) => { Assert.IsType <RustlersRibs>(rr); }
         );
 }
示例#2
0
 public void FilterByCaloriesWithOnlyMaxShouldReturnItemsWithDesiredCalories()
 {
     Assert.Collection(
         Menu.FilterByCalories(Menu.CompleteMenu(), null, 0),
         (w) => { Assert.IsType <Water>(w); }
         );
 }
示例#3
0
 public void FilterByCaloriesWithOnlyMinShouldReturnItemsWithDesiredCalories()
 {
     Assert.Collection(
         Menu.FilterByCalories(Menu.CompleteMenu(), 800, null),
         (rr) => { Assert.IsType <RustlersRibs>(rr); }
         );
 }
示例#4
0
 public void FilterByCaloriesShouldReturnItemsWithDesiredCalories()
 {
     Assert.Collection(
         Menu.FilterByCalories(Menu.CompleteMenu(), 10, 100),
         (tt) => { Assert.IsType <TexasTea>(tt); }
         );
 }
示例#5
0
 public void FilterByPriceWithOnlyMaxShouldReturnItemsWithDesiredPrice()
 {
     Assert.Collection(
         Menu.FilterByPrice(Menu.CompleteMenu(), null, .5),
         (w) => { Assert.IsType <Water>(w); }
         );
 }
示例#6
0
        public async Task GetManufacturersTest()
        {
            var manufacturers = new List <Manufacturer>
            {
                new Manufacturer()
                {
                    Name = "Said", Address = "USA LA"
                },
                new Manufacturer()
                {
                    Name = "Said", Address = "USA LA"
                },
            };

            var fakeRepositoryMock = new Mock <IManufacturerRepository>();

            fakeRepositoryMock.Setup(x => x.GetManufacturers()).ReturnsAsync(manufacturers);


            var manufacturerService = new ManufacturerService(fakeRepositoryMock.Object);

            var resultManufacturers = await manufacturerService.GetManufacturers();

            Assert.Collection(resultManufacturers, manufacturer =>
            {
                Assert.Equal("Said", manufacturer.Name);
            },
                              manufacturer =>
            {
                Assert.Equal("USA LA", manufacturer.Address);
            });
        }
示例#7
0
        public async Task SearchTest()
        {
            var movies = new List <Drug>
            {
                new Drug()
                {
                    Name = "Korvalol", Type = "For heart", Description = "heart for designed medicine"
                },
                new Drug()
                {
                    Name = "Korvalol", Type = "For heart", Description = "heart for designed medicine"
                },
            };

            var fakeRepositoryMock = new Mock <IDrugRepository>();

            fakeRepositoryMock.Setup(x => x.GetDrugWithPredicate(It.IsAny <Expression <Func <Drug, bool> > >())).ReturnsAsync(movies);


            var drugService = new DrugService(fakeRepositoryMock.Object);

            var resultDrugs = await drugService.Search("Dias");

            Assert.Collection(resultDrugs, drug =>
            {
                Assert.Equal("Korvalol", drug.Name);
            },
                              drug =>
            {
                Assert.Equal("For heart", drug.Type);
            });
        }
示例#8
0
        public async Task SearchTest()
        {
            var movies = new List <Order>
            {
                new Order()
                {
                    StartTime = new DateTime(2019, 11, 16)
                },
                new Order()
                {
                    StartTime = new DateTime(2019, 11, 15)
                },
            };

            var fakeRepositoryMock = new Mock <IOrderRepository>();

            fakeRepositoryMock.Setup(x => x.GetOrderWithPredicate(It.IsAny <Expression <Func <Order, bool> > >())).ReturnsAsync(movies);


            var orderService = new OrderService(fakeRepositoryMock.Object);

            var resultOrders = await orderService.Search("Dias");

            Assert.Collection(resultOrders, order =>
            {
                Assert.Equal("16.11.2019", order.StartTime.ToString("dd.MM.yyyy"));
            },
                              order =>
            {
                Assert.Equal("15.11.2019", order.StartTime.ToString("dd.MM.yyyy"));
            });
        }
示例#9
0
 public void SearchShouldReturnSearchedTerm()
 {
     Assert.Collection(
         Menu.Search(Menu.CompleteMenu(), "Chicken"),
         (ac) => { Assert.IsType <AngryChicken>(ac); }
         );
 }
示例#10
0
        public async Task GetDoctorsTest()
        {
            var doctors = new List <Doctor>
            {
                new Doctor()
                {
                    Firstname = "Dias", Lastname = "Isabekov", Certificate = "IITU doctor"
                },
                new Doctor()
                {
                    Firstname = "Said", Lastname = "Isabekov", Certificate = "IITU doctor"
                },
            };

            var fakeRepositoryMock = new Mock <IDoctorRepository>();

            fakeRepositoryMock.Setup(x => x.GetDoctors()).ReturnsAsync(doctors);


            var doctorService = new DoctorService(fakeRepositoryMock.Object);

            var resultDoctors = await doctorService.GetDoctors();

            Assert.Collection(resultDoctors, doctor =>
            {
                Assert.Equal("Dias", doctor.Firstname);
            },
                              doctor =>
            {
                Assert.Equal("Isabekov", doctor.Lastname);
            });
        }
示例#11
0
        public async Task GetPatientsTest()
        {
            var patients = new List <Patient>
            {
                new Patient()
                {
                    Firstname = "Said", Lastname = "Isabekov"
                },
                new Patient()
                {
                    Firstname = "Said", Lastname = "Isabekov"
                },
            };

            var fakeRepositoryMock = new Mock <IPatientRepository>();

            fakeRepositoryMock.Setup(x => x.GetPatients()).ReturnsAsync(patients);


            var patientService = new PatientService(fakeRepositoryMock.Object);

            var resultPatients = await patientService.GetPatients();

            Assert.Collection(resultPatients, patient =>
            {
                Assert.Equal("Said", patient.Firstname);
            },
                              patient =>
            {
                Assert.Equal("Isabekov", patient.Lastname);
            });
        }
示例#12
0
        public async Task SearchTest()
        {
            var movies = new List <Patient>
            {
                new Patient()
                {
                    Firstname = "Dias", Lastname = "Said"
                },
                new Patient()
                {
                    Firstname = "Said", Lastname = "Said"
                },
            };

            var fakeRepositoryMock = new Mock <IPatientRepository>();

            fakeRepositoryMock.Setup(x => x.GetPatientWithPredicate(It.IsAny <Expression <Func <Patient, bool> > >())).ReturnsAsync(movies);


            var patientService = new PatientService(fakeRepositoryMock.Object);

            var resultPatients = await patientService.Search("Dias");

            Assert.Collection(resultPatients, patient =>
            {
                Assert.Equal("Dias", patient.Firstname);
            },
                              patient =>
            {
                Assert.Equal("Said", patient.Lastname);
            });
        }
示例#13
0
        public async Task SearchTest()
        {
            var movies = new List <Manufacturer>
            {
                new Manufacturer()
                {
                    Name = "Dias"
                },
                new Manufacturer()
                {
                    Name = "Said"
                },
            };

            var fakeRepositoryMock = new Mock <IManufacturerRepository>();

            fakeRepositoryMock.Setup(x => x.GetManufacturerWithPredicate(It.IsAny <Expression <Func <Manufacturer, bool> > >())).ReturnsAsync(movies);


            var manufacturerService = new ManufacturerService(fakeRepositoryMock.Object);

            var resultManufacturers = await manufacturerService.Search("Dias");

            Assert.Collection(resultManufacturers, manufacturer =>
            {
                Assert.Equal("Dias", manufacturer.Name);
            },
                              manufacturer =>
            {
                Assert.Equal("Said", manufacturer.Name);
            });
        }
示例#14
0
        public async Task SearchTest()
        {
            var movies = new List <Prescription>
            {
                new Prescription()
                {
                    PatientName = "Dias"
                },
                new Prescription()
                {
                    PatientName = "Said"
                },
            };

            var fakeRepositoryMock = new Mock <IPrescriptionRepository>();

            fakeRepositoryMock.Setup(x => x.GetPrescriptionWithPredicate(It.IsAny <Expression <Func <Prescription, bool> > >())).ReturnsAsync(movies);


            var prescriptionService = new PrescriptionService(fakeRepositoryMock.Object);

            var resultPrescriptions = await prescriptionService.Search("Dias");

            Assert.Collection(resultPrescriptions, prescription =>
            {
                Assert.Equal("Dias", prescription.PatientName);
            },
                              prescription =>
            {
                Assert.Equal("Said", prescription.PatientName);
            });
        }
示例#15
0
        public async Task GetOrdersTest()
        {
            var orders = new List <Order>
            {
                new Order()
                {
                    StartTime = new DateTime(2019, 11, 16)
                },
                new Order()
                {
                    StartTime = new DateTime(2019, 11, 16)
                },
            };

            var fakeRepositoryMock = new Mock <IOrderRepository>();

            fakeRepositoryMock.Setup(x => x.GetOrders()).ReturnsAsync(orders);


            var orderService = new OrderService(fakeRepositoryMock.Object);

            var resultOrders = await orderService.GetOrders();

            Assert.Collection(resultOrders, order =>
            {
                Assert.Equal("16.11.19", order.StartTime.ToString("dd.MM.yy"));
            },
                              order =>
            {
                Assert.Equal("16.11.19", order.StartTime.ToString("dd.MM.yy"));
            });
        }
示例#16
0
        public async Task GetPrescriptionsTest()
        {
            var prescriptions = new List <Prescription>
            {
                new Prescription()
                {
                    PatientName = "Said", Instruction = "Not for a child", Frequency = "2 times a day"
                },
                new Prescription()
                {
                    PatientName = "Said", Instruction = "Not for a child", Frequency = "2 times a day"
                },
            };

            var fakeRepositoryMock = new Mock <IPrescriptionRepository>();

            fakeRepositoryMock.Setup(x => x.GetPrescriptions()).ReturnsAsync(prescriptions);


            var prescriptionService = new PrescriptionService(fakeRepositoryMock.Object);

            var resultPrescriptions = await prescriptionService.GetPrescriptions();

            Assert.Collection(resultPrescriptions, prescription =>
            {
                Assert.Equal("Said", prescription.PatientName);
            },
                              prescription =>
            {
                Assert.Equal("Not for a child", prescription.Instruction);
            });
        }
示例#17
0
        public async Task GetDrugsTest()
        {
            var drugs = new List <Drug>
            {
                new Drug()
                {
                    Name = "Korvalol", Type = "For heart", Description = "heart for designed medicine"
                },
                new Drug()
                {
                    Name = "Korvalol", Type = "For heart", Description = "heart for designed medicine"
                },
            };

            var fakeRepositoryMock = new Mock <IDrugRepository>();

            fakeRepositoryMock.Setup(x => x.GetDrugs()).ReturnsAsync(drugs);


            var drugService = new DrugService(fakeRepositoryMock.Object);

            var resultDrugs = await drugService.GetDrugs();

            Assert.Collection(resultDrugs, drug =>
            {
                Assert.Equal("Korvalol", drug.Name);
            },
                              drug =>
            {
                Assert.Equal("For heart", drug.Type);
            });
        }
示例#18
0
        public async Task GetOrganizationsTest()
        {
            var organizations = new List <Organization>
            {
                new Organization()
                {
                    Name = "Said", Address = "IITU Zhandosov st."
                },
                new Organization()
                {
                    Name = "Said", Address = "IITU Zhandosov st."
                },
            };

            var fakeRepositoryMock = new Mock <IOrganizationRepository>();

            fakeRepositoryMock.Setup(x => x.GetOrganizations()).ReturnsAsync(organizations);


            var organizationService = new OrganizationService(fakeRepositoryMock.Object);

            var resultOrganizations = await organizationService.GetOrganizations();

            Assert.Collection(resultOrganizations, organization =>
            {
                Assert.Equal("Said", organization.Name);
            },
                              organization =>
            {
                Assert.Equal("IITU Zhandosov st.", organization.Address);
            });
        }
示例#19
0
        public async Task SearchTest()
        {
            var doctors = new List <Doctor>
            {
                new Doctor()
                {
                    Firstname = "Dias"
                },
                new Doctor()
                {
                    Firstname = "Said", Lastname = "Doctorov"
                },
            };

            var fakeRepositoryMock = new Mock <IDoctorRepository>();

            fakeRepositoryMock.Setup(x => x.GetDoctorWithPredicate(It.IsAny <Expression <Func <Doctor, bool> > >())).ReturnsAsync(doctors);


            var doctorService = new DoctorService(fakeRepositoryMock.Object);

            var resultDoctors = await doctorService.Search("Dias");

            Assert.Collection(resultDoctors, doctor =>
            {
                Assert.Equal("Dias", doctor.Firstname);
            },
                              doctor =>
            {
                Assert.Equal("Doctorov", doctor.Lastname);
            });
        }
示例#20
0
        public void Assertions()
        {
            var condition = false;
            var text      = "something";
            var obj       = new Auto();
            var tokens    = new List <string> {
                "public", "void", "return"
            };
            var zero           = 8 - 8;
            var someEnumerable = new List <string>();

            Assert.False(condition);
            Assert.Equal("something", text);
            Assert.NotEqual("something else", text);
            Assert.Contains("tech", "technology"); // also DoesNotContain
            Assert.Matches(".*thing$", "something");
            Assert.Throws <DivideByZeroException>(() => 4 / zero);
            Assert.Empty(someEnumerable); // also NotEmpty
            Assert.IsType <Auto>(obj);
            Assert.Collection(new List <int> {
                2, 4
            },
                              n => Assert.Equal(2, n),
                              n => Assert.Equal(4, n)
                              );
            Assert.All(new List <string> {
                "a", "ab", "abc"
            },
                       s => s.StartsWith("a"));
        }
示例#21
0
 public void MenuSidesShouldContainExpectedSides()
 {
     Assert.Collection(
         Menu.Sides(),
         (bb) => { Assert.IsType <BakedBeans>(bb); },
         (ccf) => { Assert.IsType <ChiliCheeseFries>(ccf); },
         (cd) => { Assert.IsType <CornDodgers>(cd); },
         (pdc) => { Assert.IsType <PanDeCampo>(pdc); }
         );
 }
示例#22
0
 public void MenuDrinksShouldContainExpectedDrinks()
 {
     Assert.Collection(
         Menu.Drinks(),
         (cc) => { Assert.IsType <CowboyCoffee>(cc); },
         (js) => { Assert.IsType <JerkedSoda>(js); },
         (tt) => { Assert.IsType <TexasTea>(tt); },
         (w) => { Assert.IsType <Water>(w); }
         );
 }
示例#23
0
 public void MenuEntreesShouldContainExpectedEntrees()
 {
     Assert.Collection(
         Menu.Entrees(),
         (ac) => { Assert.IsType <AngryChicken>(ac); },
         (cc) => { Assert.IsType <CowpokeChili>(cc); },
         (ddb) => { Assert.IsType <DakotaDoubleBurger>(ddb); },
         (ppp) => { Assert.IsType <PecosPulledPork>(ppp); },
         (rr) => { Assert.IsType <RustlersRibs>(rr); },
         (ttb) => { Assert.IsType <TexasTripleBurger>(ttb); },
         (tb) => { Assert.IsType <TrailBurger>(tb); }
         );
 }
示例#24
0
        public void FilterByCategoryShouldReturnItemsFromDesiredCategory()
        {
            var category = new List <string>()
            {
                "Entree"
            };

            Assert.Collection(
                Menu.FilterByCategory(Menu.CompleteMenu(), category),
                (ac) => { Assert.IsType <AngryChicken>(ac); },
                (cc) => { Assert.IsType <CowpokeChili>(cc); },
                (ddb) => { Assert.IsType <DakotaDoubleBurger>(ddb); },
                (ppp) => { Assert.IsType <PecosPulledPork>(ppp); },
                (rr) => { Assert.IsType <RustlersRibs>(rr); },
                (ttb) => { Assert.IsType <TexasTripleBurger>(ttb); },
                (tb) => { Assert.IsType <TrailBurger>(tb); }
                );
        }
示例#25
0
 public void MenuCompleteMenuShouldContainAllMenuItems()
 {
     Assert.Collection(
         Menu.CompleteMenu(),
         (ac) => { Assert.IsType <AngryChicken>(ac); },
         (cc) => { Assert.IsType <CowpokeChili>(cc); },
         (ddb) => { Assert.IsType <DakotaDoubleBurger>(ddb); },
         (ppp) => { Assert.IsType <PecosPulledPork>(ppp); },
         (rr) => { Assert.IsType <RustlersRibs>(rr); },
         (ttb) => { Assert.IsType <TexasTripleBurger>(ttb); },
         (tb) => { Assert.IsType <TrailBurger>(tb); },
         (bb) => { Assert.IsType <BakedBeans>(bb); },
         (ccf) => { Assert.IsType <ChiliCheeseFries>(ccf); },
         (cd) => { Assert.IsType <CornDodgers>(cd); },
         (pdc) => { Assert.IsType <PanDeCampo>(pdc); },
         (cc) => { Assert.IsType <CowboyCoffee>(cc); },
         (js) => { Assert.IsType <JerkedSoda>(js); },
         (tt) => { Assert.IsType <TexasTea>(tt); },
         (w) => { Assert.IsType <Water>(w); }
         );
 }
        public void GetGlnAssociations_GetAssociations()
        {
            // Arrange
            // Create fake data
            var gln2 = new Gln();

            gln2.Id = 2;
            gln2.FriendlyDescriptionPurpose = "two";
            _dbContext.Glns.Add(gln2);

            var gln3 = new Gln();

            gln3.Id = 3;
            gln3.FriendlyDescriptionPurpose = "three";
            _dbContext.Glns.Add(gln3);

            var association1 = new GlnAssociation();

            association1.Id     = 1;
            association1.GlnId1 = 1;
            association1.GlnId2 = 2;

            _dbContext.GlnAssociations.Add(association1);

            var association2 = new GlnAssociation();

            association2.Id     = 2;
            association2.GlnId1 = 1;
            association2.GlnId2 = 3;

            _dbContext.GlnAssociations.Add(association2);

            // Act
            var result = _glnRepository.GetGlnAssociations(1);

            // Check
            Assert.Equal(2, result.Count());
            Assert.Collection(result, item => Assert.Contains("two", item.FriendlyDescriptionPurpose),
                              item => Assert.Contains("three", item.FriendlyDescriptionPurpose));
        }