예제 #1
0
        public void CalculateShouldSetEmptyPasswordValueWithNoCalculator()
        {
            const string UserName = "******";
            ICredentials target = new Credentials(UserName);

            target.Calculate();

            Assert.AreEqual(target.Password, string.Empty);
        }
예제 #2
0
        public void CalculateShouldSetPasswordWithUserNameHashCodeValue()
        {
            const string Username = "******";

            ICredentials credentials = new Credentials(Username);
            IPasswordGenerator target = new HashPasswordGenerator();
            target.Generate(credentials);

            Assert.AreEqual(Username.GetHashCode().ToString(CultureInfo.InvariantCulture), credentials.Password);
        }
예제 #3
0
        public void CalculateShouldSetPasswordValueExpectedUsingCalculator()
        {
            const string Password = "******";

            Mock<IPasswordGenerator> mock = this.MoqRepository.Create<IPasswordGenerator>();
            mock.Setup(x => x.Generate(It.IsAny<ICredentials>()))
                .Callback((ICredentials c) => { c.Password = Password; });

            IPasswordGenerator generator = mock.Object;
            ICredentials credentials = new Credentials(generator, "Me");
            credentials.Calculate();

            Assert.AreEqual(Password, credentials.Password);
            mock.Verify();
        }