Esempio n. 1
0
        public void IsSatisfiedBy_ThereAreMoreThan30Chars_False()
        {
            var target    = new DeveloperMustHaveValidUsernameSpecification();
            var developer = new Developer()
            {
                Username = "******"
            };

            Assert.IsFalse(target.IsSatisfiedBy(developer));
            Assert.AreEqual(target.NotSatisfiedReason, "Username max length is 30 chars.");
        }
Esempio n. 2
0
        public void IsSatisfiedBy_LessThan1Chars_False()
        {
            var target    = new DeveloperMustHaveValidUsernameSpecification();
            var developer = new Developer()
            {
                Username = ""
            };

            Assert.IsFalse(target.IsSatisfiedBy(developer));
            Assert.AreEqual(target.NotSatisfiedReason, "Username must have at least 1 char.");
        }
Esempio n. 3
0
        public void IsSatisfiedBy_ThereAreInvalidChars_False()
        {
            var target    = new DeveloperMustHaveValidUsernameSpecification();
            var developer = new Developer()
            {
                Username = "******"
            };

            Assert.IsFalse(target.IsSatisfiedBy(developer));
            Assert.AreEqual(target.NotSatisfiedReason, "Username must have only valid chars: letters, numbers and _.");

            developer.Username = "******";
            Assert.IsFalse(target.IsSatisfiedBy(developer));
            Assert.AreEqual(target.NotSatisfiedReason, "Username must have only valid chars: letters, numbers and _.");

            developer.Username = "******";
            Assert.IsFalse(target.IsSatisfiedBy(developer));
            Assert.AreEqual(target.NotSatisfiedReason, "Username must have only valid chars: letters, numbers and _.");
        }
Esempio n. 4
0
        public void IsSatisfiedBy_Valid_True()
        {
            var target    = new DeveloperMustHaveValidUsernameSpecification();
            var developer = new Developer()
            {
                Username = "******"
            };

            Assert.IsTrue(target.IsSatisfiedBy(developer));

            developer.Username = "******";
            Assert.IsTrue(target.IsSatisfiedBy(developer));

            developer.Username = "******";
            Assert.IsTrue(target.IsSatisfiedBy(developer));

            developer.Username = "******";
            Assert.IsTrue(target.IsSatisfiedBy(developer));

            developer.Username = "******";
            Assert.IsTrue(target.IsSatisfiedBy(developer));
        }
Esempio n. 5
0
        private static Developer MapDeveloperFromProviderResult(DotNetOpenAuth.AspNet.AuthenticationResult clientResult)
        {
            var dev = new Developer()
            {
                Username = DeveloperUI.GetUsernameFromEmail(clientResult.UserName)
            };

            dev.Username = DeveloperMustHaveValidUsernameSpecification.RemoveUsernameInvalidChars(dev.Username);

            var data = clientResult.ExtraData;

            if (data.ContainsKey("email"))
            {
                dev.Email = data["email"];
            }

            if (data.ContainsKey("fullName"))
            {
                dev.FullName = data["fullName"];
            }

            return(dev);
        }
Esempio n. 6
0
 public void RemoveUsernameInvalidChars_InvalidChars_CharsRemoved()
 {
     Assert.AreEqual("1234567890_asdfghjkl", DeveloperMustHaveValidUsernameSpecification.RemoveUsernameInvalidChars("1234567890-=!@#$%&*()_ asdfghjkl;'"));
 }