예제 #1
0
        public void DisplayName_OnlyLastNameSet_ReturnsUsername()
        {
            var prophandler = DummyFactory.GetPropertyHandler("username");

            prophandler.LastName = "Doe";
            Assert.AreEqual("username", prophandler.DisplayName);
        }
예제 #2
0
        public void GetProperty_SetTheValueInDefaultContext_ReturnsCorrectValue()
        {
            var prophandler = DummyFactory.GetPropertyHandler();

            prophandler.SetProperty("Country", "Hello World");
            Assert.AreEqual("Hello World", prophandler.GetProperty("Country").Value);
        }
예제 #3
0
        public void LastLockoutDate_PropertyNotDefiendInCommonNamesAndIsThereforNotSet_ReturnsDefaultValueAfterSet()
        {
            var prophandler = DummyFactory.GetPropertyHandler();

            prophandler.LastLockoutDate = DateTime.UtcNow;
            Assert.AreEqual(DateTime.MinValue, prophandler.LastLockoutDate);
        }
예제 #4
0
        public void DisplayName_LastNameNotSet_ReturnsFirstnameAndUsername()
        {
            var prophandler = DummyFactory.GetPropertyHandler("username");

            prophandler.FirstName = "John";
            Assert.AreEqual("John (username)", prophandler.DisplayName);
        }
예제 #5
0
        public void GetValue_SetTheValueInDefaultContext_ReturnsCorrectValue()
        {
            var prophandler = DummyFactory.GetPropertyHandler();

            prophandler.SetProperty("Description", "Hello World");
            Assert.AreEqual("Hello World", prophandler.GetValue <string>("Description"));
        }
예제 #6
0
        public void GetValue_GetNonExistingProperty_ReturnsDefaultValue()
        {
            var prophandler = DummyFactory.GetPropertyHandler();
            var result      = prophandler.GetValue <DateTime>("NonExistantDate");

            Assert.AreEqual(DateTime.MinValue, result);
        }
예제 #7
0
        public void CommonNameProperties_SetAndGetSameValue()
        {
            var prophandler = DummyFactory.GetPropertyHandler("username");

            prophandler.FullName                = "fullname";
            prophandler.FirstName               = "firstname";
            prophandler.LastName                = "lastname";
            prophandler.Description             = "description";
            prophandler.Email                   = "*****@*****.**";
            prophandler.HomePage                = "http://code.google.com/p/njupiter/";
            prophandler.StreetAddress           = "street addres";
            prophandler.Company                 = "company";
            prophandler.City                    = "city";
            prophandler.Telephone               = "+46123456";
            prophandler.Fax                     = "+416456789";
            prophandler.HomeTelephone           = "+46789123";
            prophandler.MobileTelephone         = "+46070123";
            prophandler.PostOfficeBox           = "office box";
            prophandler.PostalCode              = "12356";
            prophandler.Country                 = "sweden";
            prophandler.Title                   = "geek";
            prophandler.Active                  = true;
            prophandler.PasswordQuestion        = "yeah what?";
            prophandler.PasswordAnswer          = "31137";
            prophandler.LastActivityDate        = DateTime.MaxValue;
            prophandler.CreationDate            = DateTime.MaxValue;
            prophandler.LastLoginDate           = DateTime.MaxValue;
            prophandler.LastPasswordChangedDate = DateTime.MaxValue;
            prophandler.Locked                  = true;
            prophandler.LastUpdatedDate         = DateTime.MaxValue;
            prophandler.IsAnonymous             = true;
            Assert.AreEqual("fullname", prophandler.FullName);
            Assert.AreEqual("firstname", prophandler.FirstName);
            Assert.AreEqual("lastname", prophandler.LastName);
            Assert.AreEqual("description", prophandler.Description);
            Assert.AreEqual("*****@*****.**", prophandler.Email);
            Assert.AreEqual("http://code.google.com/p/njupiter/", prophandler.HomePage);
            Assert.AreEqual("street addres", prophandler.StreetAddress);
            Assert.AreEqual("company", prophandler.Company);
            Assert.AreEqual("city", prophandler.City);
            Assert.AreEqual("+46123456", prophandler.Telephone);
            Assert.AreEqual("+416456789", prophandler.Fax);
            Assert.AreEqual("+46789123", prophandler.HomeTelephone);
            Assert.AreEqual("+46070123", prophandler.MobileTelephone);
            Assert.AreEqual("office box", prophandler.PostOfficeBox);
            Assert.AreEqual("12356", prophandler.PostalCode);
            Assert.AreEqual("sweden", prophandler.Country);
            Assert.AreEqual("geek", prophandler.Title);
            Assert.AreEqual(true, prophandler.Active);
            Assert.AreEqual("yeah what?", prophandler.PasswordQuestion);
            Assert.AreEqual("31137", prophandler.PasswordAnswer);
            Assert.AreEqual(DateTime.MaxValue, prophandler.LastActivityDate);
            Assert.AreEqual(DateTime.MaxValue, prophandler.CreationDate);
            Assert.AreEqual(DateTime.MaxValue, prophandler.LastLoginDate);
            Assert.AreEqual(DateTime.MaxValue, prophandler.LastPasswordChangedDate);
            Assert.AreEqual(DateTime.MaxValue, prophandler.LastUpdatedDate);
            Assert.AreEqual(true, prophandler.Locked);
            Assert.AreEqual(true, prophandler.IsAnonymous);
        }
예제 #8
0
        public void MakeReadOnly_CheckObjectAndDefaultProperties_ReturnsTrue()
        {
            var prophandler = DummyFactory.GetPropertyHandler("username");

            prophandler.MakeReadOnly();
            Assert.IsTrue(prophandler.IsReadOnly);
            Assert.IsTrue(prophandler.GetProperties().IsReadOnly);
        }
예제 #9
0
        public void DisplayName_FullNameSet_ReturnsFullname()
        {
            var prophandler = DummyFactory.GetPropertyHandler("username");

            prophandler.FirstName = "John";
            prophandler.LastName  = "Doe";
            prophandler.FullName  = "Mr. John Doe";
            Assert.AreEqual("Mr. John Doe", prophandler.DisplayName);
        }
예제 #10
0
        public void UserName_SetUserName_ReturnsSetValue()
        {
            var prophandler = DummyFactory.GetPropertyHandler("username");

            prophandler.SetProperty(prophandler.PropertyNames.UserName,
                                    prophandler.PropertyNames.ContextNames.UserName,
                                    "newusername");
            Assert.AreEqual("newusername", prophandler.UserName);
        }
예제 #11
0
        public void AttachProperties_AttachAlreadyAttachedContext_ThrowsArgumentException()
        {
            var prophandler = DummyFactory.GetPropertyHandler();

            var attachedProperties = DummyFactory.GetPropertyCollection(12);

            prophandler.AttachProperties(attachedProperties);
            Assert.Throws <ArgumentException>(() => prophandler.AttachProperties(attachedProperties));
        }
예제 #12
0
        public void Indexer_TryGetProperty8FromDefaultContext_ReturnsSameAsMethod()
        {
            var prophandler = DummyFactory.GetPropertyHandler();
            var property    = prophandler.GetProperty("FirstName");

            property.Value = "Hello world";
            Assert.AreEqual(property, prophandler["FirstName"]);
            Assert.AreEqual("Hello world", prophandler["FirstName"].Value);
        }
예제 #13
0
        public void Indexer_TryGetFirstPropertyFromContext_ReturnsProperty()
        {
            var prophandler        = DummyFactory.GetPropertyHandler();
            var attachedProperties = DummyFactory.GetPropertyCollection(12);

            prophandler.AttachProperties(attachedProperties);
            var firstProperty = attachedProperties.First();

            Assert.AreEqual(firstProperty, prophandler[firstProperty.Name, firstProperty.Context]);
        }
예제 #14
0
        public void AttachProperties_PropertyCollectionWithMishmatchingSchemaTypes_ThrowsArgumentException()
        {
            var prophandler = DummyFactory.GetPropertyHandler();

            var propertyList       = DummyFactory.GetPropertyList(12);
            var schema             = DummyFactory.GetSchema <int>("property", 12);
            var attachedProperties = new PropertyCollection(propertyList, schema);

            Assert.Throws <ArgumentException>(() => prophandler.AttachProperties(attachedProperties));
        }
예제 #15
0
        public void SetProperty_SetPropertyInOtherContextAndReadTheCommonName_ReturnsSetValue()
        {
            var prophandler        = DummyFactory.GetPropertyHandler();
            var anotherContext     = new Context("AnotherContext");
            var attachedProperties = DummyFactory.GetPropertyCollection(12, anotherContext);

            prophandler.AttachProperties(attachedProperties);
            prophandler.SetProperty(prophandler.PropertyNames.Department, prophandler.PropertyNames.ContextNames.Department, "Hello World");
            Assert.AreEqual("Hello World", prophandler.Department);
        }
예제 #16
0
        public void GetProperty_SetCommonName_ReturnsPropertyWithSetValue()
        {
            var prophandler = DummyFactory.GetPropertyHandler();

            prophandler.Title = "Hello world";
            var prop = prophandler.GetProperty(prophandler.PropertyNames.Title, prophandler.PropertyNames.ContextNames.Title);

            Assert.NotNull(prop);
            Assert.AreEqual("Hello world", prop.Value);
            Assert.AreEqual(prop.Value, prophandler.Title);
        }
예제 #17
0
        public void AttachProperties_AttachCollectionForContext_ContextAttached()
        {
            var prophandler = DummyFactory.GetPropertyHandler();

            var context            = new Context("context");
            var attachedProperties = DummyFactory.GetPropertyCollection(12, context);

            prophandler.AttachProperties(attachedProperties);

            Assert.IsTrue(prophandler.AttachedContexts.Contains(context));
            Assert.AreEqual(attachedProperties, prophandler.GetProperties(context));
        }
예제 #18
0
        public void AttachProperties_PropertyCollectionWithMishmatchingContext_ThrowsArgumentException()
        {
            var prophandler = DummyFactory.GetPropertyHandler();

            var propertyList = DummyFactory.GetPropertyList(12);

            propertyList.Add(new Property <string>("property13", new Context("othercontext"), CultureInfo.InvariantCulture));
            var schema             = DummyFactory.GetSchema <int>("property", 13);
            var attachedProperties = new PropertyCollection(propertyList, schema);

            Assert.Throws <ArgumentException>(() => prophandler.AttachProperties(attachedProperties));
        }
예제 #19
0
        public void AttachProperties_AttachCollectionForContext_AnotherContextNotAttached()
        {
            var prophandler = DummyFactory.GetPropertyHandler();

            var context            = new Context("context");
            var attachedProperties = DummyFactory.GetPropertyCollection(12, context);

            prophandler.AttachProperties(attachedProperties);
            var anotherContext = new Context("anotherContext");

            Assert.IsFalse(prophandler.AttachedContexts.Contains(anotherContext));
            Assert.IsNull(prophandler.GetProperties(anotherContext));
        }
예제 #20
0
        public void MakeReadOnly_AttachContextAfterReadonly_AttachContextBecomesReadonly()
        {
            var prophandler = DummyFactory.GetPropertyHandler("username");

            prophandler.MakeReadOnly();

            var anotherContext     = new Context("AnotherContext");
            var attachedProperties = DummyFactory.GetPropertyCollection(12, anotherContext);

            prophandler.AttachProperties(attachedProperties);

            Assert.Throws <ReadOnlyException>(() => prophandler.Department = "Other Department");
        }
예제 #21
0
        public void CreateWritable_AttachContextAfterReadonly_AttachContextBecomesReadonly()
        {
            var prophandler = DummyFactory.GetPropertyHandler("username");

            prophandler.MakeReadOnly();

            var anotherContext     = new Context("AnotherContext");
            var attachedProperties = DummyFactory.GetPropertyCollection(12, anotherContext);

            prophandler.AttachProperties(attachedProperties);

            var newprophander = prophandler.CreateWritable();

            Assert.AreNotSame(prophandler, newprophander);

            newprophander.StreetAddress = "Other Address";
            newprophander.Department    = "Other Department";

            Assert.AreEqual("Other Address", newprophander.StreetAddress);
            Assert.AreEqual("Other Department", newprophander.Department);
            Assert.AreNotEqual("Other Address", prophandler.StreetAddress);
            Assert.AreNotEqual("Other Department", prophandler.Department);
        }
예제 #22
0
        public void GetName_NoSupportedName_TrhowsNotSupportedException()
        {
            var commonNames = DummyFactory.GetDummyCommonNames();

            Assert.Throws <NotSupportedException>(() => commonNames.GetName("NonExistantName"));
        }
예제 #23
0
        public void GetProperties_PassingNull_ThrowsArgumentNullException()
        {
            var prophandler = DummyFactory.GetPropertyHandler();

            Assert.Throws <ArgumentNullException>(() => prophandler.GetProperties(null));
        }
예제 #24
0
        public void GetProperty_PassingNullContext_ThrowsArgumentNullException()
        {
            var prophandler = DummyFactory.GetPropertyHandler();

            Assert.Throws <ArgumentNullException>(() => prophandler.GetProperty("MyProperty", (IContext)null));
        }
예제 #25
0
        public void SetProperty_PassingNonExistingPropertyName_ThrowsArgumentException()
        {
            var prophandler = DummyFactory.GetPropertyHandler();

            Assert.Throws <ArgumentException>(() => prophandler.SetProperty("NoExisingPropertyName", null));
        }
예제 #26
0
        public void SetProperty_PassingNonExistingContext_ThrowsArgumentException()
        {
            var prophandler = DummyFactory.GetPropertyHandler();

            Assert.Throws <ArgumentException>(() => prophandler.SetProperty(prophandler.FirstName, "NonExisgingContext", null));
        }
예제 #27
0
        public void UserName_NoUserNameIsSet_ReturnsDefault()
        {
            var prophandler = DummyFactory.GetPropertyHandler("username");

            Assert.AreEqual("username", prophandler.UserName);
        }