Esempio n. 1
0
        public void DestroyRoom_RoomNotExist_ThrowsDbUpdateConcurrencyException()
        {
            using (var db = new Db(SqliteInMemory.CreateOptions <Db>()))
            {
                db.Database.EnsureCreated();
                _roomService = new RoomService(db, _mapperMock.Object);
                _roomService.AttachAndDestroyRoom(5);

                Assert.Throws <DbUpdateConcurrencyException>(() => db.SaveChanges());
            }
        }
Esempio n. 2
0
        public void DestroyRoom_RoomExist_RoomRemoved()
        {
            var room = new Room {
                HostNick = "aa"
            };

            using (var db = new Db(SqliteInMemory.CreateOptions <Db>()))
            {
                db.Database.EnsureCreated();
                db.Rooms.Add(room);
                db.SaveChanges();

                _roomService = new RoomService(db, _mapperMock.Object);

                db.Entry(room).State = EntityState.Detached;
                _roomService.AttachAndDestroyRoom(room.Id);
                db.SaveChanges();

                Assert.IsTrue(db.Rooms.Find(room.Id) == null);
            }
        }