Exemplo n.º 1
0
        public async Task CanInsertDto()
        {
            var simpleDto = new SimpleWithFkDto {
                Key = 8, Value = "test", Fk = 1
            };
            await _dao.TryInsertOrUpdateAsync(simpleDto).ConfigureAwait(false);

            var loadAll = _dbContextBuilder().Set <SimpleWithFkEntity>().ToList();

            Assert.IsTrue(loadAll.Count == 1);
            Assert.IsTrue(loadAll.First().Key == 8);
            Assert.IsTrue(loadAll.First().Value == "test");
        }
Exemplo n.º 2
0
        public async Task AutoIncrementIsWorking()
        {
            var simpleDto = new SimpleWithFkDto {
                Key = 0, Value = "test", Fk = 1
            };
            var result = await _dao.TryInsertOrUpdateAsync(simpleDto).ConfigureAwait(false);

            var loadAll = _dbContextBuilder().Set <SimpleWithFkEntity>().ToList();

            Assert.IsTrue(loadAll.Count == 1);
            Assert.IsTrue(loadAll.First().Key == 1);
            Assert.IsTrue(loadAll.First().Value == "test");

            Assert.IsTrue(result.Key == 1);
            Assert.IsTrue(result.Value == "test");
        }
Exemplo n.º 3
0
        public async Task CanReplaceDto()
        {
            var otherContext = _dbContextBuilder();

            otherContext.Set <SimpleWithFkEntity>().Add(new SimpleWithFkEntity {
                Key = 8, Value = "test", Fk = 1
            });
            await otherContext.SaveChangesAsync().ConfigureAwait(false);

            var simpleDto = new SimpleWithFkDto {
                Key = 8, Value = "blabla", Fk = 1
            };
            await _dao.TryInsertOrUpdateAsync(simpleDto).ConfigureAwait(false);

            var loadAll = _dbContextBuilder().Set <SimpleWithFkEntity>().ToList();

            Assert.IsTrue(loadAll.Count == 1);
            Assert.IsTrue(loadAll.First().Key == 8);
            Assert.IsTrue(loadAll.First().Value == "blabla");
        }