Exemple #1
0
        public async Task Check_DeleteNotExistRelationThrowsException(int firstId, int secondId)
        {
            //Arrange
            var cls = new InMemoryAppDbContext();

            using (var context = cls.GetContextWithData())
            {
                IItemRelationRepository repo          = new ItemRelationRepository(context);
                ItemRelation            startRelation = context.ItemsRelations.Find(firstId, secondId);
                startRelation.FirstItemId -= 100;
                await Assert.ThrowsAsync <InvalidOperationException>(() => repo.DeleteRecordAsync(startRelation));

                context.Database.EnsureDeleted();
            }
        }
Exemple #2
0
        public async Task Check_DeleteRelationWorkingRight(int firstId, int secondId)
        {
            //Arrange
            var cls = new InMemoryAppDbContext();

            using (var context = cls.GetContextWithData())
            {
                IItemRelationRepository repo          = new ItemRelationRepository(context);
                ItemRelation            startRelation = context.ItemsRelations.Find(firstId, secondId);

                await repo.DeleteRecordAsync(startRelation);

                var actualRelation = context.ItemsRelations.Find(firstId, secondId);

                Assert.NotNull(startRelation);
                Assert.Null(actualRelation);

                context.Database.EnsureDeleted();
            }
        }