Esempio n. 1
0
        public async void GetListFacilitiesModel_FromInitializedDbTables_LogicFacilitiesModelEqualExpectedFacilitiesModel()
        {
            // arrange
            var facilities    = GetFacilities();
            var techProcesses = GetTechProcesses();

            fixture.db.Facility.AddRange(facilities);
            fixture.db.TechProcess.AddRange(techProcesses);
            await fixture.db.SaveChangesAsync();


            var expected = new List <FacilitiesModel>
            {
                new FacilitiesModel
                {
                    Id            = 44440,
                    Name          = "Test facility #1",
                    Latitude      = (decimal)12.3456,
                    Longitude     = (decimal)78.9012,
                    TechProcesses = new List <TechProcess>()
                },
                new FacilitiesModel
                {
                    Id            = 44441,
                    Name          = "Test facility #2",
                    Latitude      = (decimal)78.9012,
                    Longitude     = (decimal)12.3456,
                    TechProcesses = new List <TechProcess>()
                }
            };

            foreach (var facility in expected)
            {
                foreach (var techProcess in techProcesses.Where(i => i.FacilityId == facility.Id))
                {
                    facility.TechProcesses.Add(techProcess);
                }
            }

            // act
            var actual = (await logic.GetAllDataModelAsync()).ToList();

            // assert
            foreach (var expectedItem in expected)
            {
                Assert.Contains(actual, actualItem =>
                                expectedItem.Id == actualItem.Id &&
                                expectedItem.Name == actualItem.Name &&
                                expectedItem.Latitude == actualItem.Latitude &&
                                expectedItem.Longitude == actualItem.Longitude);
                foreach (var techProcess in expectedItem.TechProcesses)
                {
                    var actualTechProcesses = actual.Single(i => i.Id == expectedItem.Id).TechProcesses;
                    Assert.Contains(actualTechProcesses, actualTechProcess =>
                                    actualTechProcess.FacilityId == techProcess.FacilityId &&
                                    actualTechProcess.RecipeId == techProcess.RecipeId &&
                                    actualTechProcess.DayEfficiency == techProcess.DayEfficiency);
                }
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Index(int currentPage = 1, int itemsOnPage = 20)
        {
            var model = await logic.GetAllDataModelAsync();

            // form pagenation model
            var pagenationModel = new Pagenation <FacilitiesModel>(model, itemsOnPage, currentPage);

            return(View(pagenationModel));
        }