private async Task UpdateKey <T>() where T : DictionaryElementBase, new()
        {
            using var context = PrepareData.GetDbContext(); var service = new GenericDictionaryService <T>(context);
            var dictionaryElement = new DictionaryElementEditDTO()
            {
                Id = 1000
            };
            var result = await service.UpdateKey(dictionaryElement);

            Assert.True(result.IsLeft);
        }
        private async Task UpdateKey <T>(string name, string newName) where T : DictionaryElementBase, new()
        {
            using var context = PrepareData.GetDbContext(); var service = new GenericDictionaryService <T>(context);
            var element           = context.Set <T>().FirstOrDefault(e => e.Name == name);
            var dictionaryElement = new DictionaryElementEditDTO()
            {
                Id   = element.Id,
                Name = newName
            };
            var result = await service.UpdateKey(dictionaryElement);

            Assert.True(result.IsLeft);
        }
Beispiel #3
0
        private async Task UpdateKey <T>(string name) where T : DictionaryElementBase, new()
        {
            using var context = PrepareData.GetDbContext(); var service = new GenericDictionaryService <T>(context);
            var element           = context.Set <T>().AsNoTracking().FirstOrDefault(e => e.Name == name);
            var dictionaryElement = new DictionaryElementEditDTO()
            {
                Id   = element.Id,
                Name = "elo"
            };
            var result = await service.UpdateKey(dictionaryElement);

            Assert.True(result.IsRight);
            var value = context.Set <T>().AsNoTracking().FirstOrDefault(e => e.Id == element.Id);

            Assert.Equal("elo", value.Name);
        }