Ejemplo n.º 1
0
            async Task HasValues()
            {
                var repo = mockup.Get <IValueRepository>();
                await repo.AddRange(new ValueInput[] { ValueTests.CreateInput(), ValueTests.CreateInput(), ValueTests.CreateInput() });

                Assert.True(await repo.HasValues());
            }
Ejemplo n.º 2
0
            async Task Add()
            {
                var repo   = mockup.Get <IValueRepository>();
                var result = await repo.Add(ValueTests.CreateInput());

                Assert.NotNull(result);
            }
Ejemplo n.º 3
0
            async Task Add()
            {
                var controller = mockup.Get <LotsaValuesController>();

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

                Assert.NotNull(result);
            }
Ejemplo n.º 4
0
            void EntityToView()
            {
                var mapper = mockup.Get <AppMapper>();
                var entity = ValueTests.CreateEntity();
                var view   = mapper.MapValue(entity, new Value());

                Assert.Equal(entity.ValueId, view.ValueId);
                AssertEqual(entity, view);
            }
Ejemplo n.º 5
0
            void InputToEntity()
            {
                var mapper = mockup.Get <AppMapper>();
                var input  = ValueTests.CreateInput();
                var entity = mapper.MapValue(input, new ValueEntity());

                //Make sure the id does not copy over
                Assert.Equal(default(Int32), entity.ValueId);
                AssertEqual(input, entity);
            }
Ejemplo n.º 6
0
            async Task Update()
            {
                var repo   = mockup.Get <IValueRepository>();
                var result = await repo.Add(ValueTests.CreateInput());

                Assert.NotNull(result);
                var updateResult = await repo.Update(result.CrazyKey, ValueTests.CreateInput());

                Assert.NotNull(updateResult);
            }
Ejemplo n.º 7
0
            async Task Update()
            {
                var controller = mockup.Get <LotsaValuesController>();

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

                Assert.NotNull(result);

                var updateResult = await controller.Update(result.ValueId, ValueTests.CreateInput());

                Assert.NotNull(updateResult);
            }
Ejemplo n.º 8
0
            async Task Get()
            {
                var dbContext = mockup.Get <AppDbContext>();
                var repo      = mockup.Get <IValueRepository>();
                await repo.AddRange(new ValueInput[] { ValueTests.CreateInput(), ValueTests.CreateInput(), ValueTests.CreateInput() });

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

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

                Assert.NotNull(getResult);
            }
            async Task Delete()
            {
                var dbContext = mockup.Get <AppDbContext>();
                var repo      = mockup.Get <IValueRepository>();
                await repo.AddRange(new ValueInput[] { ValueTests.CreateInput(), ValueTests.CreateInput(), ValueTests.CreateInput() });

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

                Assert.Equal <int>(4, dbContext.Values.Count());
                await repo.Delete(result.ValueId);

                Assert.Equal <int>(3, dbContext.Values.Count());
            }
Ejemplo n.º 10
0
            async Task List()
            {
                //This could be more complete
                var repo = mockup.Get <IValueRepository>();
                await repo.AddRange(new ValueInput[] { ValueTests.CreateInput(), ValueTests.CreateInput(), ValueTests.CreateInput() });

                var query  = new ValueQuery();
                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);
            }
Ejemplo n.º 11
0
            async Task Delete()
            {
                var controller = mockup.Get <LotsaValuesController>();

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

                Assert.NotNull(result);

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

                Assert.Equal(1, listResult.Total);

                await controller.Delete(result.ValueId);

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

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

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

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

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

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

                Assert.NotNull(result);
            }
Ejemplo n.º 13
0
            async Task List()
            {
                var totalItems = 3;

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

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

                var query  = new ValueQuery();
                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);
            }
Ejemplo n.º 14
0
 async Task AddRange()
 {
     var repo = mockup.Get <IValueRepository>();
     await repo.AddRange(new ValueInput[] { ValueTests.CreateInput(), ValueTests.CreateInput(), ValueTests.CreateInput() });
 }