Ejemplo n.º 1
0
        public void NewEmptyUsrnIsNotNull()
        {
            //Check that reference isn't empty
            var sut = new Usrn();

            Assert.NotNull(sut);
        }
Ejemplo n.º 2
0
        public void UsrnisIusrn()
        {
            //Test to see if USRN is an instance of IUSRN
            var sut = new Usrn();

            Assert.That(sut,
                        Is.InstanceOf(typeof(IUsrn)));
        }
Ejemplo n.º 3
0
        public void EmptyValueGivesIsValidFalse()
        {
            //Test to ensure an empty value is recorded as not being a valid result
            var sut    = new Usrn();
            var actual = sut.IsValid();

            Assert.False(actual);
        }
Ejemplo n.º 4
0
        public void ConstructorAcceptsLong()
        {
            //Check that long values are accepted
            long test = 1234;
            var  sut  = new Usrn(test);

            Assert.NotNull(sut);
        }
Ejemplo n.º 5
0
        public void EmptyValueIsEmpty()
        {
            //Test to ensure no other value is returned if nothing is passed
            var sut    = new Usrn();
            var actual = sut.IsEmpty();

            Assert.AreEqual(actual,
                            true);
        }
Ejemplo n.º 6
0
        public void DefaultIsRecognised()
        {
            var input = new Usrn();

            var actual = input.IsDefault();

            Assert.That(actual,
                        Is.True);
        }
Ejemplo n.º 7
0
        public void ValidUsrnIsValid()
        {
            var input = new Usrn(123);

            var actual = input.IsValid();

            Assert.That(actual,
                        Is.True);
        }
Ejemplo n.º 8
0
        public void ValidUsrnIsNotDefault()
        {
            var input = new Usrn(123);


            var actual = input.IsDefault();

            Assert.That(actual,
                        Is.False);
        }
Ejemplo n.º 9
0
        public void InvalidStringIsValidFalse([Values("abc",
                                                      "def",
                                                      "!$%^")]
                                              string value)
        {
            var sut    = new Usrn(value);
            var actual = sut.IsValid();

            Assert.False(actual);
        }
Ejemplo n.º 10
0
        public void InvalidStringIsEmpty([Values("abc",
                                                 "def",
                                                 "!$$%")]
                                         string value)
        {
            var sut    = new Usrn(value);
            var actual = sut.IsEmpty();

            Assert.True(actual);
        }
Ejemplo n.º 11
0
        public void UsrnHasCorrectValue()
        {
            //Check to see the USRN contains a correct value, and this is passed correctly
            long expected = 12345;
            var  sut      = new Usrn(expected);
            var  actual   = sut.Value;

            Assert.AreEqual(actual,
                            expected);
        }
Ejemplo n.º 12
0
        public void NonEmptyValueIsNotEmpty()
        {
            //Test to ensure that any passed value that isn't empty is recorded as not being empty
            const long value  = 12345;
            var        sut    = new Usrn(value);
            var        actual = sut.IsEmpty();

            Assert.AreEqual(actual,
                            false);
        }
Ejemplo n.º 13
0
        public void WierdLongValuesAreNotValid([Values(-1,
                                                       0,
                                                       01234567890123)]
                                               long input)
        {
            var usrn   = new Usrn(input);
            var actual = usrn.IsValidUsrn(input);

            Assert.That(actual,
                        Is.False);
        }
Ejemplo n.º 14
0
        public void ConstructorAcceptsString([Values("hello world",
                                                     "12345",
                                                     "Sample",
                                                     "!£$$^&*():")]
                                             string test)
        {
            //Check that string values are accepted
            var sut = new Usrn(test);

            Assert.NotNull(sut);
        }
Ejemplo n.º 15
0
        public void UsrnIsInequal(
            [Values(1, 2, 3)] int x,
            [Values("", "12")] string s)
        {
            var numUsrn = new Usrn(x);

            var stringUsrn = new Usrn(s);

            var actual = numUsrn != stringUsrn;

            Assert.That(actual, Is.True);
        }
Ejemplo n.º 16
0
        public void SensibleStringValuesAreValid([Values("1",
                                                         "8090",
                                                         "012345678901",
                                                         "        23     ")]
                                                 string input)
        {
            var usrn   = new Usrn(input);
            var actual = usrn.IsValidUsrn(input);

            Assert.That(actual,
                        Is.True);
        }
Ejemplo n.º 17
0
        public void SensibleLongValuesAreValid([Values(1,
                                                       8090,
                                                       012345678901,
                                                       23)]
                                               long input)
        {
            var usrn   = new Usrn(input);
            var actual = usrn.IsValidUsrn(input);

            Assert.That(actual,
                        Is.True);
        }
Ejemplo n.º 18
0
        public void WierdValuesAreNotValid([Values("",
                                                   "-1",
                                                   "01234567890123",
                                                   "e",
                                                   "uprn",
                                                   "   0.12")]
                                           string input)
        {
            var usrn   = new Usrn(input);
            var actual = usrn.IsValidUsrn(input);

            Assert.That(actual,
                        Is.False);
        }
Ejemplo n.º 19
0
        public void UsrnIsNotEqual(
            [Values(1, 2, 3)] int x,
            [Values("", "12")] string s)
        {
            var numUsrn = new Usrn(x);

            var stringUsrn = new Usrn(s);

            var actual = numUsrn == stringUsrn;

            Assert.That(actual, Is.False);

            Assert.That(numUsrn, Is.Not.EqualTo(stringUsrn));
        }
Ejemplo n.º 20
0
        public void AssignedZeroOrNegativeUprnValueIsNull([Values(0,
                                                                  -1,
                                                                  -300)]
                                                          int usrn)
        {
            var sut = new Usrn {
                Value = usrn
            };
            var actual = sut.Value;

            long?expected = sut.NullUsrnValue;

            Assert.That(actual,
                        Is.EqualTo(expected));
        }
Ejemplo n.º 21
0
        /// <inheritdoc />
        public bool ValidUsrn(long usrn)
        {
            var _usrn = new Usrn(usrn);

            return(_usrn.IsValid());
        }
Ejemplo n.º 22
0
        public void CanSerialiseContact()
        {
            var title    = "title";
            var surname  = "surname";
            var forename = "forename";


            var person = new Person {
                Title = title, Surname = surname, Forename = forename
            };

            var address1 = "add1";
            var address2 = "add2";
            var address3 = "add3";
            var address4 = "add4";
            var address5 = "add5";
            var uprn     = new Uprn("12345");
            var usrn     = new Usrn();

            var address = new Address(address1, address2, address3, address4, address5, null)
            {
                Uprn = uprn, Usrn = usrn
            };

            var mobile    = new TelephoneNumber("123");
            var preferred = new TelephoneNumber("789");

            var sut = new Contact
            {
                Address        = address,
                HomePhone      = new TelephoneNumber(),
                MobilePhone    = new TelephoneNumber("123"),
                Person         = person,
                PreferredPhone = new TelephoneNumber("789")
            };

            var serialised = sut.ToJson();

            Assert.That(serialised, Is.Not.Null.Or.Empty);
            Assert.That(serialised.Length, Is.GreaterThan(40));

            var deserialised = serialised.FromJson <Contact>();

            Assert.That(deserialised, Is.Not.Null.Or.Empty);

            Assert.That(deserialised.Person, Is.Not.Null);
            Assert.That(deserialised.Person.Title, Is.EqualTo(title));
            Assert.That(deserialised.Person.GivenName, Is.EqualTo(forename));
            Assert.That(deserialised.Person.FamilyName, Is.EqualTo(surname));

            Assert.That(deserialised.Address, Is.Not.Null.Or.Empty);

            var actualAddress = deserialised.Address;

            Assert.That(actualAddress.Address1, Is.EqualTo(address1));
            Assert.That(actualAddress.Address2, Is.EqualTo(address2));
            Assert.That(actualAddress.Address3, Is.EqualTo(address3));
            Assert.That(actualAddress.Address4, Is.EqualTo(address4));
            Assert.That(actualAddress.Address5, Is.EqualTo(address5));
            Assert.That(actualAddress.Uprn, Is.Not.Null);

            Assert.That(actualAddress.Uprn.Value.ToString(), Is.EqualTo(uprn.Value.ToString()));

            Assert.That(deserialised.PreferredPhone, Is.Not.Null.Or.Empty);
            Assert.That(deserialised.PreferredPhone.Value, Is.EqualTo(preferred.Value));
            Assert.That(deserialised.MobilePhone, Is.Not.Null.Or.Empty);
            Assert.That(deserialised.MobilePhone.Value, Is.EqualTo(mobile.Value));
        }