Example #1
0
        public void AddressShouldBeTakenFromFormattedAddressIfNull()
        {
            const string addressFormat    = "1";
            const string buildingNumber   = "15a";
            const string addressLineOne   = "15a North Street";
            const string townCity         = "CARSHALTON";
            const string postalCode       = "SM5 2HW";
            const string countryIso       = "GBR";
            const string country          = "UK";
            const string formattedAddress = "15a North Street\nCARSHALTON\nSM5 2HW\nUK";

            const string addressString =
                "{     \"" + AddressFormatJson + "\": " + addressFormat
                + ",     \"" + BuildingNumberJson + "\": \"" + buildingNumber
                + "\",     \"" + AddressLineOneJson + "\": \"" + addressLineOne
                + "\",     \"" + TownCityJson + "\": \"" + townCity
                + "\",     \"" + PostalCodeJson + "\": \"" + postalCode
                + "\",     \"" + CountryIsoJson + "\": \"" + countryIso
                + "\",     \"" + CountryJson + "\": \"" + country
                + "\",     \"" + FormattedAddressJson + "\": \"" + formattedAddress + "\" }";

            var attribute = new ProtoBuf.Attribute.Attribute
            {
                Name        = Constants.UserProfile.StructuredPostalAddressAttribute,
                ContentType = ContentType.Json,
                Value       = ByteString.CopyFromUtf8(addressString)
            };

            _yotiProfile = TestTools.Profile.CreateUserProfileWithSingleAttribute <Dictionary <string, JToken> >(attribute);

            ActivityDetailsParser.SetAddressToBeFormattedAddressIfNull(_yotiProfile);

            Assert.AreEqual(_yotiProfile.Address.GetValue(), formattedAddress);
        }
        public void UnsuccessfulResponseShouldThrowYotiProfileException()
        {
            var response = new Response
            {
                Success = false
            };

            Assert.ThrowsException <YotiProfileException>(() =>
            {
                ActivityDetailsParser.HandleResponse(KeyPair.Get(), response.Content);
            });
        }
        public void NullOrEmptyContentShouldThrowProfileException()
        {
            var response = new Response
            {
                Success = true,
                Content = ""
            };

            Assert.ThrowsException <YotiProfileException>(() =>
            {
                ActivityDetailsParser.HandleResponse(KeyPair.Get(), response.Content);
            });
        }