コード例 #1
0
        public async Task TestGetAllStores()
        {
            var provider = CommonTestUtils.InitializeDatabaseProvider();

            provider.AddStore(new Store()
            {
                Address = "Test Address1", Name = "TestName1"
            });
            provider.AddStore(new Store()
            {
                Address = "Test Address2", Name = "TestName2"
            });
            await provider.Save();

            var controller = new StoresController(provider, CommonTestUtils.InitializeMapper());
            var result     = controller.GetStores();

            var okResult = Assert.IsType <OkObjectResult>(result);
            var model    = Assert.IsAssignableFrom <StoresListResponseDto>(okResult.Value);

            Assert.Equal(2, model.Stores.Count);
            Assert.Equal(2, model.TotalElements);
            Assert.Equal(200, okResult.StatusCode);
            return;
        }
コード例 #2
0
ファイル: StoreControllerTest.cs プロジェクト: ronbak/gapTest
        public void Get()
        {
            // Arrange
            StoresController controller = new StoresController();

            // Act
            IEnumerable <Store> stores = controller.GetStores();

            // Assert
            Assert.IsNotNull(stores);
            Assert.AreEqual(3, stores.Count());
            var testStore = new Store {
                id = 1, Name = "Store 1", Address = "Street 1"
            };

            Assert.AreEqual(stores, testStore);
        }