コード例 #1
0
        public void DeleteEntityInvalidTypeTest()
        {
            var user1 = new User {
                Id        = Guid.NewGuid(),
                FirstName = "test1"
            };

            var user2 = new User {
                Id        = Guid.NewGuid(),
                FirstName = "test2"
            };

            var userList = new List <User> {
                user1,
                user2
            };

            var mockInitialiter = new Mock <IDatabaseInitializer>();

            mockInitialiter.Setup(x => x.InitializeTasks()).Returns(new List <Task>());
            mockInitialiter.Setup(x => x.InitializeUsers()).Returns(userList);

            var context = new InMemoryDataContext(mockInitialiter.Object);

            var user3 = "test";

            context.DeleteEntity(user3);
        }
コード例 #2
0
        public void DeleteEntityNotFoundTest()
        {
            var user1 = new User {
                Id        = Guid.NewGuid(),
                FirstName = "test1"
            };

            var user2 = new User {
                Id        = Guid.NewGuid(),
                FirstName = "test2"
            };

            var userList = new List <User> {
                user1,
                user2
            };

            var mockInitialiter = new Mock <IDatabaseInitializer>();

            mockInitialiter.Setup(x => x.InitializeTasks()).Returns(new List <Task>());
            mockInitialiter.Setup(x => x.InitializeUsers()).Returns(userList);

            var context = new InMemoryDataContext(mockInitialiter.Object);

            var user3 = new User {
                Id        = Guid.NewGuid(),
                FirstName = "user3"
            };

            context.DeleteEntity(user3);

            Assert.AreEqual(2, context.Users.Count());
        }