Ejemplo n.º 1
0
        public void GetUserMustReturnNullThereIsntAMatch()
        {
            //Arrange
            var mockContext = new Mock<DataContext>();
            var userProfileDbSet = new FakeDbSet<UserProfile>();
            mockContext
                .Setup(context => context.UserProfiles)
                .Returns(userProfileDbSet);

            var sut = new AccountService(() => mockContext.Object);

            //Act
            var match = sut.GetUser("username");

            //Assert
            Assert.IsNull(match);
        }
Ejemplo n.º 2
0
        public void GetUserMustReturnMatchingUserName()
        {
            //Arrange
            var mockContext = new Mock<DataContext>();
            var userProfile = new UserProfile
                {
                    UserId = 3,
                    UserName = "******"
                };
            var userProfileDbSet = new FakeDbSet<UserProfile>(new[]
                {
                    userProfile,
                    new UserProfile {UserId = 4, UserName = "******"}
                });
            mockContext
                .Setup(context => context.UserProfiles)
                .Returns(userProfileDbSet);

            var sut = new AccountService(() => mockContext.Object);

            //Act
            var match = sut.GetUser("username");

            //Assert
            Assert.AreEqual(3, match.UserId);
        }