コード例 #1
0
        public async Task <IActionResult> Index(int currentPage = 1, int itemsOnPage = 20)
        {
            var model = await logic.GetAllDataModelAsync();

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

            return(View(pagenationModel));
        }
コード例 #2
0
        public async void GetListStoragesModel_FromInitializedDbTables_LogicStoragesModelsEqualExpectedStoragesModels()
        {
            var storages  = GetStorages();
            var products  = GetProducts();
            var companies = GetCompanies();

            fixture.db.Company.AddRange(companies);
            fixture.db.Storage.AddRange(storages);
            fixture.db.Product.AddRange(products);
            await fixture.db.SaveChangesAsync();

            var expected = new List <StoragesModel>
            {
                new StoragesModel
                {
                    Id        = 44440,
                    Name      = "Test storage #1",
                    Latitude  = (decimal)12.3456,
                    Longitude = (decimal)78.9012,
                    Company   = new ValueTuple <string, int> {
                        Item2 = 44440, Item1 = "Company #1"
                    },
                    ProductsCount = 2
                },
                new StoragesModel
                {
                    Id        = 44441,
                    Name      = "Test storage #2",
                    Latitude  = (decimal)12.3456,
                    Longitude = (decimal)78.9012,
                    Company   = new ValueTuple <string, int> {
                        Item2 = 44440, Item1 = "Company #1"
                    },
                    ProductsCount = 1
                },
                new StoragesModel
                {
                    Id        = 44442,
                    Name      = "Test storage #3",
                    Latitude  = (decimal)12.3456,
                    Longitude = (decimal)78.9012,
                    Company   = new ValueTuple <string, int> {
                        Item2 = 44441, Item1 = "Company #2"
                    },
                    ProductsCount = 1
                }
            };

            // 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 &&
                                expectedItem.Company.Item2 == actualItem.Company.Item2 &&
                                expectedItem.Company.Item1 == actualItem.Company.Item1 &&
                                expectedItem.ProductsCount == actualItem.ProductsCount);
            }
        }