async Task HasLefts()
            {
                var repo = mockup.Get <ILeftRepository>();
                await repo.AddRange(new LeftInput[] { LeftTests.CreateInput(), LeftTests.CreateInput(), LeftTests.CreateInput() });

                Assert.True(await repo.HasLefts());
            }
            async Task Add()
            {
                var repo   = mockup.Get <ILeftRepository>();
                var result = await repo.Add(LeftTests.CreateInput());

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

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

                Assert.NotNull(result);
            }
Exemplo n.º 4
0
            void InputToEntity()
            {
                var mapper = mockup.Get <AppMapper>();
                var input  = LeftTests.CreateInput();
                var entity = mapper.MapLeft(input, new LeftEntity());

                //Make sure the id does not copy over
                Assert.Equal(default(Guid), entity.LeftId);
                AssertEqual(input, entity);
            }
            async Task Update()
            {
                var repo   = mockup.Get <ILeftRepository>();
                var result = await repo.Add(LeftTests.CreateInput());

                Assert.NotNull(result);
                var updateResult = await repo.Update(result.LeftId, LeftTests.CreateInput());

                Assert.NotNull(updateResult);
            }
            async Task Update()
            {
                var controller = mockup.Get <LeftsController>();

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

                Assert.NotNull(result);

                var updateResult = await controller.Update(result.LeftId, LeftTests.CreateInput());

                Assert.NotNull(updateResult);
            }
            async Task Get()
            {
                var dbContext = mockup.Get <AppDbContext>();
                var repo      = mockup.Get <ILeftRepository>();
                await repo.AddRange(new LeftInput[] { LeftTests.CreateInput(), LeftTests.CreateInput(), LeftTests.CreateInput() });

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

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

                Assert.NotNull(getResult);
            }
            async Task List()
            {
                //This could be more complete
                var repo = mockup.Get <ILeftRepository>();
                await repo.AddRange(new LeftInput[] { LeftTests.CreateInput(), LeftTests.CreateInput(), LeftTests.CreateInput() });

                var query  = new LeftQuery();
                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 <LeftsController>();

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

                Assert.NotNull(result);

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

                Assert.Equal(1, listResult.Total);

                await controller.Delete(result.LeftId);

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

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

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

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

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

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

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

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

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

                var query  = new LeftQuery();
                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);
            }
 async Task AddRange()
 {
     var repo = mockup.Get <ILeftRepository>();
     await repo.AddRange(new LeftInput[] { LeftTests.CreateInput(), LeftTests.CreateInput(), LeftTests.CreateInput() });
 }