Esempio n. 1
0
            async Task HasStores()
            {
                var repo = mockup.Get <IStoreRepository>();
                await repo.AddRange(new StoreInput[] { StoreTests.CreateInput(), StoreTests.CreateInput(), StoreTests.CreateInput() });

                Assert.True(await repo.HasStores());
            }
Esempio n. 2
0
            async Task Add()
            {
                var repo   = mockup.Get <IStoreRepository>();
                var result = await repo.Add(StoreTests.CreateInput());

                Assert.NotNull(result);
            }
            async Task Add()
            {
                var controller = mockup.Get <StoresController>();

                var result = await controller.Add(StoreTests.CreateInput());

                Assert.NotNull(result);
            }
Esempio n. 4
0
            void EntityToView()
            {
                var mapper = mockup.Get <AppMapper>();
                var entity = StoreTests.CreateEntity();
                var view   = mapper.MapStore(entity, new Store());

                Assert.Equal(entity.StoreId, view.StoreId);
                AssertEqual(entity, view);
            }
Esempio n. 5
0
            async Task Update()
            {
                var repo   = mockup.Get <IStoreRepository>();
                var result = await repo.Add(StoreTests.CreateInput());

                Assert.NotNull(result);
                var updateResult = await repo.Update(result.StoreId, StoreTests.CreateInput());

                Assert.NotNull(updateResult);
            }
Esempio n. 6
0
            void InputToEntity()
            {
                var mapper = mockup.Get <AppMapper>();
                var input  = StoreTests.CreateInput();
                var entity = mapper.MapStore(input, new StoreEntity());

                //Make sure the id does not copy over
                Assert.Equal(default(Guid), entity.StoreId);
                AssertEqual(input, entity);
            }
            async Task Update()
            {
                var controller = mockup.Get <StoresController>();

                var result = await controller.Add(StoreTests.CreateInput());

                Assert.NotNull(result);

                var updateResult = await controller.Update(result.StoreId, StoreTests.CreateInput());

                Assert.NotNull(updateResult);
            }
Esempio n. 8
0
            async Task Get()
            {
                var dbContext = mockup.Get <AppDbContext>();
                var repo      = mockup.Get <IStoreRepository>();
                await repo.AddRange(new StoreInput[] { StoreTests.CreateInput(), StoreTests.CreateInput(), StoreTests.CreateInput() });

                var result = await repo.Add(StoreTests.CreateInput());

                Assert.Equal <int>(4, dbContext.Stores.Count());
                var getResult = await repo.Get(result.StoreId);

                Assert.NotNull(getResult);
            }
Esempio n. 9
0
            async Task List()
            {
                //This could be more complete
                var repo = mockup.Get <IStoreRepository>();
                await repo.AddRange(new StoreInput[] { StoreTests.CreateInput(), StoreTests.CreateInput(), StoreTests.CreateInput() });

                var query  = new StoreQuery();
                var result = await repo.List(query);

                Assert.Equal(query.Limit, result.Limit);
                Assert.Equal(query.Offset, result.Offset);
                Assert.Equal(3, result.Total);
                Assert.NotEmpty(result.Items);
            }
            async Task Delete()
            {
                var controller = mockup.Get <StoresController>();

                var result = await controller.Add(StoreTests.CreateInput());

                Assert.NotNull(result);

                var listResult = await controller.List(new StoreQuery());

                Assert.Equal(1, listResult.Total);

                await controller.Delete(result.StoreId);

                listResult = await controller.List(new StoreQuery());

                Assert.Equal(0, listResult.Total);
            }
            async Task Get()
            {
                var totalItems = 3;

                var controller = mockup.Get <StoresController>();

                for (var i = 0; i < totalItems; ++i)
                {
                    Assert.NotNull(await controller.Add(StoreTests.CreateInput()));
                }

                //Manually add the item we will look back up
                var lookup = await controller.Add(StoreTests.CreateInput());

                var result = await controller.Get(lookup.StoreId);

                Assert.NotNull(result);
            }
            async Task List()
            {
                var totalItems = 3;

                var controller = mockup.Get <StoresController>();

                for (var i = 0; i < totalItems; ++i)
                {
                    Assert.NotNull(await controller.Add(StoreTests.CreateInput()));
                }

                var query  = new StoreQuery();
                var result = await controller.List(query);

                Assert.Equal(query.Limit, result.Limit);
                Assert.Equal(query.Offset, result.Offset);
                Assert.Equal(3, result.Total);
                Assert.NotEmpty(result.Items);
            }
Esempio n. 13
0
 async Task AddRange()
 {
     var repo = mockup.Get <IStoreRepository>();
     await repo.AddRange(new StoreInput[] { StoreTests.CreateInput(), StoreTests.CreateInput(), StoreTests.CreateInput() });
 }