Ejemplo n.º 1
0
        public async void GetUser_Valid_NotNull_Test()
        {
            //Arrange
            const int idToRead = 0;
            _repositoryMock.Setup(r => r.Read(idToRead)).Returns(Task.FromResult(_storedUser));
            var userFacade = new UserAdapter(_repositoryMock.Object);

            //Act
            var returnedUser = await userFacade.Read(idToRead);

            //Assert
            Assert.IsNotNull(returnedUser);
        }
Ejemplo n.º 2
0
        public async void GetUser_Valid_CorrectUserInfo_Test()
        {
            //Arrange
            const int idToRead = 0;
            _repositoryMock.Setup(r => r.Read(idToRead)).Returns(Task.FromResult(_storedUser));
            var adapter = new UserAdapter(_repositoryMock.Object);

            //Act
            var returnedUser = await adapter.Read(idToRead);

            //Assert
            Assert.IsTrue(_user.Name == returnedUser.Name);
            Assert.IsTrue(_user.MetaData == returnedUser.MetaData);
            Assert.IsTrue(_user.Id == returnedUser.Id);
        }
Ejemplo n.º 3
0
        public async void GetUser_Valid_IsUser_Test()
        {
            //Arrange
            const int idToRead = 0;
            _repositoryMock.Setup(r => r.Read(idToRead)).Returns(Task.FromResult(_storedUser));
            var adapter = new UserAdapter(_repositoryMock.Object);

            //Act
            var returnedUser = await adapter.Read(idToRead);

            //Assert
            Assert.IsInstanceOfType(returnedUser, typeof (User));
        }
Ejemplo n.º 4
0
        public void GetAllUsers_Valid_ReturnsCorrectUsers_Test()
        {
            //Arrange
            var user1 = new StoredUser {Name = "name1", MetaData = "metaData1"};
            var user2 = new StoredUser {Name = "name2", MetaData = "metaData2"};
            var user3 = new StoredUser {Name = "name3", MetaData = "metaData3"};
            var list = new List<StoredUser> {user1, user2, user3}.AsQueryable();
            _repositoryMock.Setup(r => r.Read()).Returns(list);
            var adapter = new UserAdapter(_repositoryMock.Object);

            //Act
            var result = adapter.Read();
            var actualUsers = result.ToList();

            //Assert
            var counter = 0;
            foreach (var actualUser in list.AsEnumerable())
            {
                var returnedUser = actualUsers[counter];
                Assert.IsTrue(returnedUser.Name == actualUser.Name);
                Assert.IsTrue(returnedUser.MetaData == actualUser.MetaData);
                Assert.IsTrue(returnedUser.Id == actualUser.Id);
                counter++;
            }
        }
Ejemplo n.º 5
0
        public void GetAllUsers_Valid_ReturnsCorrectNumberOfUsers_Test()
        {
            //Arrange
            var user1 = new StoredUser {Name = "name1", MetaData = "metaData1"};
            var user2 = new StoredUser {Name = "name2", MetaData = "metaData2"};
            var user3 = new StoredUser {Name = "name3", MetaData = "metaData3"};
            var list = new List<StoredUser> {user1, user2, user3}.AsQueryable();
            _repositoryMock.Setup(r => r.Read()).Returns(list);
            var adapter = new UserAdapter(_repositoryMock.Object);
            const int expectedCount = 3;

            //Act
            var result = adapter.Read();
            var actualCount = result.ToList().Count;

            //Assert
            Assert.IsTrue(expectedCount == actualCount);
        }
Ejemplo n.º 6
0
        public async void GetUser_Invalid_NoExistingUser_Test()
        {
            //Arrange
            const int idToRead = 0;
            _repositoryMock.Setup(r => r.Read(idToRead));
            var adapter = new UserAdapter(_repositoryMock.Object);

            //Act
            var returnedUser = await adapter.Read(idToRead);

            //Assert
            Assert.IsNull(returnedUser);
        }