Esempio n. 1
0
        public async Task Update_MultipleEntities_EntitiesUpdated()
        {
            using var dbContextProvider = new AnyDbContextProvider(nameof(Update_MultipleEntities_EntitiesUpdated));
            var repository = new AnyRepository(dbContextProvider.DbContext, _logger);

            dbContextProvider.Mock(new AnyEntity
            {
                Id        = 1,
                AnyString = "AnyString"
            },
                                   new AnyEntity
            {
                Id        = 2,
                AnyString = "AnyString"
            });
            var expected = new[] {
                new AnyEntity
                {
                    Id        = 1,
                    AnyString = "AnyNewString"
                },
                new AnyEntity
                {
                    Id        = 2,
                    AnyString = "AnyNewString"
                }
            };

            await repository.Update(expected);

            var actual = repository.Get(1, 2);
            await repository.SaveChanges();

            actual.Should().BeEquivalentTo(expected);
        }
Esempio n. 2
0
        public async Task Update_ExistingEntityWithAutoSave_EntityUpdated()
        {
            using var dbContextProvider = new AnyDbContextProvider(nameof(Update_ExistingEntityWithAutoSave_EntityUpdated));
            var repository = new AnyRepository(dbContextProvider.DbContext, _logger)
            {
                AutoSave = true
            };

            dbContextProvider.Mock(new AnyEntity
            {
                Id        = 1,
                AnyString = "AnyString"
            });
            var expected = new AnyEntity
            {
                Id        = 1,
                AnyString = "AnyNewString"
            };

            await repository.Update(expected);

            var actual = repository.Get(1);

            actual.Single().Should().BeEquivalentTo(expected);
        }