public void PrintReturnRecipientFromForeignAddress() { //Arrange var source = new PrintReturnRecipient( "Name", new ForeignAddress( CountryIdentifier.Country, "NORGE", "Adresselinje1", "Adresselinje2", "Adresselinje3", "Adresselinje4" )); var expectedDto = new printrecipient { name = source.Name, Item = new foreignaddress { ItemElementName = ItemChoiceType2.country, Item = ((ForeignAddress)source.Address).CountryIdentifierValue, addressline1 = source.Address.AddressLine1, addressline2 = source.Address.AddressLine2, addressline3 = source.Address.AddressLine3, addressline4 = ((ForeignAddress)source.Address).Addressline4 } }; //Act var actualDto = DataTransferObjectConverter.ToDataTransferObject(source); //Assert Comparator.AssertEqual(expectedDto, actualDto); }
public void Document() { //Arrange var source = new document { subject = "testSubject", filetype = "txt", authenticationlevel = authenticationlevel.PASSWORD, sensitivitylevel = sensitivitylevel.SENSITIVE, smsnotification = new smsnotification { afterhours = new[] { 3 } }, uuid = "uuid", contenthash = new contenthash { hashalgorithm = "SHA256", Value = "5o0RMsXcgSZpGsL7FAmhSQnvGkqgOcvl5JDtMhXBSlc=" } }; IDocument expected = new Document(source.subject, source.filetype, AuthenticationLevel.Password, SensitivityLevel.Sensitive, new SmsNotification(3)) { ContentHash = new ContentHash { HashAlgoritm = source.contenthash.hashalgorithm, Value = source.contenthash.Value }, Guid = source.uuid }; //Act var actual = SendDataTransferObjectConverter.FromDataTransferObject(source); //Assert Comparator.AssertEqual(expected, actual); }
public void PrintReturnRecipientFromNorwegianAddress() { //Arrange var source = new PrintReturnRecipient( "Name", new NorwegianAddress("0001", "Oslo", "Addr1", "Addr2", "Addr3")); var expectedDto = new printrecipient { name = source.Name, Item = new norwegianaddress { zipcode = ((NorwegianAddress)source.Address).PostalCode, city = ((NorwegianAddress)source.Address).City, addressline1 = source.Address.AddressLine1, addressline2 = source.Address.AddressLine2, addressline3 = source.Address.AddressLine3 } }; //Act var actualDto = DataTransferObjectConverter.ToDataTransferObject(source); //Assert Comparator.AssertEqual(expectedDto, actualDto); }
public void SmsNotification() { //Arrange var atTimes = new List <DateTime> { DateTime.Now, DateTime.Now.AddHours(3) }; var afterHours = new List <int> { 4, 5 }; var source = new SmsNotification(); source.NotifyAfterHours.AddRange(afterHours); source.NotifyAtTimes.AddRange(atTimes); var expectedDto = new smsnotification { afterhours = afterHours.ToArray(), at = atTimes.Select(a => new listedtime { timeSpecified = true, time = a }).ToArray() }; //Act var actual = DataTransferObjectConverter.ToDataTransferObject(source); //Assert Comparator.AssertEqual(expectedDto, actual); }
public void ForeignAddress() { //Arrange var source = new ForeignAddress( CountryIdentifier.Countrycode, "SE", "Adresselinje1", "Adresselinje2", "Adresselinje3", "Adresselinje4" ); var expectedDto = new foreignaddress { ItemElementName = ItemChoiceType2.countrycode, Item = "SE", addressline1 = source.AddressLine1, addressline2 = source.AddressLine2, addressline3 = source.AddressLine3, addressline4 = source.Addressline4 }; //Act var actualDto = DataTransferObjectConverter.ToDataTransferObject(source); //Assert Comparator.AssertEqual(expectedDto, actualDto); }
public void PrintDetails() { //Arrange var source = new PrintDetails( new PrintRecipient( "Name", new NorwegianAddress("0001", "Oslo", "Addr1", "Addr2", "Addr3")), new PrintReturnRecipient( "ReturnName", new NorwegianAddress("0001", "OsloRet", "Addr1Ret", "Addr2Ret", "Addr3Ret"))); List <PrintInstruction> printinstruction = new List <PrintInstruction>(); printinstruction.Add(new PrintInstruction("test", "testing")); source.PrintInstructions = new PrintInstructions(printinstruction); var sourceAddress = source.PrintRecipient.Address; var returnAddress = source.PrintReturnRecipient.Address; var expectedDto = new printdetails { recipient = new printrecipient { name = source.PrintRecipient.Name, Item = new norwegianaddress { zipcode = ((NorwegianAddress)sourceAddress).PostalCode, city = ((NorwegianAddress)sourceAddress).City, addressline1 = sourceAddress.AddressLine1, addressline2 = sourceAddress.AddressLine2, addressline3 = sourceAddress.AddressLine3 } }, returnaddress = new printrecipient { name = source.PrintReturnRecipient.Name, Item = new norwegianaddress { zipcode = ((NorwegianAddress)returnAddress).PostalCode, city = ((NorwegianAddress)returnAddress).City, addressline1 = returnAddress.AddressLine1, addressline2 = returnAddress.AddressLine2, addressline3 = returnAddress.AddressLine3 } }, printinstructions = new printinstruction[] { new printinstruction { key = "test", value = "testing" } } }; //Act var actualDto = DataTransferObjectConverter.ToDataTransferObject(source); //Assert Comparator.AssertEqual(expectedDto, actualDto); Assert.Null(DataTransferObjectConverter.ToDataTransferObject((IPrintDetails)null)); }
public void PrintIfUnread() { //Arrange DateTime printifunreadafter = DateTime.Now.AddDays(3); PrintDetails printDetails = new PrintDetails( new PrintRecipient( "Name", new NorwegianAddress("0001", "Oslo", "Addr1", "Addr2", "Addr3")), new PrintReturnRecipient( "ReturnName", new NorwegianAddress("0001", "OsloRet", "Addr1Ret", "Addr2Ret", "Addr3Ret"))); var source = new PrintIfUnread(printifunreadafter, printDetails); var sourceAddress = source.PrintDetails.PrintRecipient.Address; var returnAddress = source.PrintDetails.PrintReturnRecipient.Address; var expectedDtoPrintDetails = new printdetails { recipient = new printrecipient { name = source.PrintDetails.PrintRecipient.Name, Item = new norwegianaddress { zipcode = ((NorwegianAddress)sourceAddress).PostalCode, city = ((NorwegianAddress)sourceAddress).City, addressline1 = sourceAddress.AddressLine1, addressline2 = sourceAddress.AddressLine2, addressline3 = sourceAddress.AddressLine3 } }, returnaddress = new printrecipient { name = source.PrintDetails.PrintReturnRecipient.Name, Item = new norwegianaddress { zipcode = ((NorwegianAddress)returnAddress).PostalCode, city = ((NorwegianAddress)returnAddress).City, addressline1 = returnAddress.AddressLine1, addressline2 = returnAddress.AddressLine2, addressline3 = returnAddress.AddressLine3 } } }; var expectedDto = new printifunread { printifunreadafter = printifunreadafter, printdetails = expectedDtoPrintDetails }; //Act var actualDto = DataTransferObjectConverter.ToDataTransferObject(source); //Assert Comparator.AssertEqual(expectedDto, actualDto); Assert.Null(DataTransferObjectConverter.ToDataTransferObject((IPrintIfUnread)null)); }
public void InboxWithEmptyListOnNullResult() { var source = new inbox(); var expected = new List <InboxDocument>(); var actual = InboxDataTransferObjectConverter.FromDataTransferObject(source); Comparator.AssertEqual(expected, actual); }
public void Message() { //Arrange var source = DomainUtility.GetMessageWithBytesAndStaticGuidRecipientById(); var expectedDto = DomainUtility.GetMessageDataTransferObjectWithBytesAndStaticGuidRecipientById(); //Act var actualDto = SendDataTransferObjectConverter.ToDataTransferObject(source); //Assert Comparator.AssertEqual(expectedDto, actualDto); }
public void SimpleConstructor() { //Arrange const string name = "name"; //Act var printRecipient = new PrintReturnRecipient(name, DomainUtility.GetNorwegianAddress()); //Assert Assert.Equal(name, printRecipient.Name); Comparator.AssertEqual(DomainUtility.GetNorwegianAddress(), printRecipient.Address); }
public void IdentificationByOrganizationNumber() { //Arrange var source = new Identification(new RecipientById(IdentificationType.OrganizationNumber, "123456789")); var expectedDto = new identification { ItemElementName = ItemChoiceType.organisationnumber, Item = ((RecipientById)source.DigipostRecipient).Id }; //Act var actualDto = DataTransferObjectConverter.ToDataTransferObject(source); //Assert Comparator.AssertEqual(expectedDto, actualDto); }
public void WithAfterHours() { //Arrange var firstSmsNotification = 2; var secondSmsNotification = 5; var expected = new List <int> { firstSmsNotification, secondSmsNotification }; ISmsNotification smsNotification = new SmsNotification(expected.ToArray()); //Act var actual = smsNotification.NotifyAfterHours; //Assert Comparator.AssertEqual(expected, actual); }
public void WithSendingTime() { //Arrange var firstSmsNotification = DateTime.Today; var secondSmsNotification = DateTime.Today.AddDays(1); var expected = new List <DateTime> { firstSmsNotification, secondSmsNotification }; ISmsNotification smsNotification = new SmsNotification(expected.ToArray()); //Act var actual = smsNotification.NotifyAtTimes; //Assert Comparator.AssertEqual(expected, actual); }
public void Invoice() { //Arrange var contentBytes = new byte[] { 0xb2 }; var smsNotification = new SmsNotification(DateTime.Today.AddHours(3)); var source = new Invoice( "subject", "txt", contentBytes, 100, "8902438456", DateTime.Today, "123123123", AuthenticationLevel.TwoFactor, SensitivityLevel.Sensitive, smsNotification); var expectedDto = new invoice { subject = source.Subject, filetype = source.FileType, authenticationlevel = source.AuthenticationLevel.ToAuthenticationLevel(), authenticationlevelSpecified = true, sensitivitylevel = source.SensitivityLevel.ToSensitivityLevel(), sensitivitylevelSpecified = true, smsnotification = new smsnotification { at = new[] { new listedtime { time = smsNotification.NotifyAtTimes.First(), timeSpecified = true } } }, uuid = source.Guid, kid = source.Kid, amount = source.Amount, account = source.Account, duedate = source.Duedate }; //Act var actualDto = SendDataTransferObjectConverter.ToDataTransferObject(source); //Assert Comparator.AssertEqual(expectedDto, actualDto); }
public void SimpleConstructor() { DateTime deadline = DateTime.Now.AddDays(3); PrintDetails printDetails = new PrintDetails(DomainUtility.GetPrintRecipientWithNorwegianAddress(), DomainUtility.GetPrintReturnRecipientWithNorwegianAddress(), PrintColors.Colors); //Arrange var printIfUnreadAfter = new PrintIfUnread( deadline, printDetails); //Act //Assert Assert.Equal(deadline, printIfUnreadAfter.PrintIfUnreadAfter); Comparator.AssertEqual(printDetails, printIfUnreadAfter.PrintDetails); }
public void MessageWithPrintDetailsAndRecipientById() { //Arrange var printDetails = DomainUtility.GetPrintDetails(); var source = DomainUtility.GetMessageWithBytesAndStaticGuidRecipientById(); source.PrintDetails = printDetails; var expectedDto = DomainUtility.GetMessageDataTransferObjectWithBytesAndStaticGuidRecipientById(); expectedDto.recipient.printdetails = DomainUtility.GetPrintDetailsDataTransferObject(); //Act var actualDto = SendDataTransferObjectConverter.ToDataTransferObject(source); //Assert Comparator.AssertEqual(expectedDto, actualDto); }
public void NorwegianAddress() { //Arrange var source = new NorwegianAddress("0001", "Oslo", "Addr1", "Addr2", "Addr3"); var expectedDto = new norwegianaddress { zipcode = source.PostalCode, city = source.City, addressline1 = source.AddressLine1, addressline2 = source.AddressLine2, addressline3 = source.AddressLine3 }; //Act var actualDto = DataTransferObjectConverter.ToDataTransferObject(source); //Assert Comparator.AssertEqual(expectedDto, actualDto); }
public void RecipientById() { //Arrange var source = new RecipientById( IdentificationType.DigipostAddress, "ola.nordmann#2233" ); var expectedDto = new messagerecipient { ItemElementName = ItemChoiceType1.digipostaddress, Item = "ola.nordmann#2233", printdetails = null //TODO: Implementer print! }; //Act var actualDto = DataTransferObjectConverter.ToDataTransferObject(source); //Assert Comparator.AssertEqual(expectedDto, actualDto); }
public void InboxDocument() { const string contentType = "txt"; const string content = "http://contenturi.no"; const string deleteUri = "http://deletecontenturi.no"; var firstAccessed = DateTime.Today.AddDays(2); var deliveryTime = DateTime.Today; const int id = 123456789; const string sender = "sender"; var source = new inboxdocument { attachment = new inboxdocument[0], authenticationlevel = authenticationlevel.PASSWORD, contenttype = contentType, contenturi = content, deleteuri = deleteUri, deliverytime = deliveryTime, firstaccessed = firstAccessed, firstaccessedSpecified = true, id = id, sender = sender }; var expected = new InboxDocument { AuthenticationLevel = AuthenticationLevel.Password, ContentType = contentType, Content = new Uri(content), Delete = new Uri(deleteUri), DeliveryTime = deliveryTime, FirstAccessed = firstAccessed, Id = id, Sender = sender }; var actual = InboxDataTransferObjectConverter.FromDataTransferObject(source); Comparator.AssertEqual(expected, actual); }
public void SimpleConstructor() { //Arrange var printDetails = new PrintDetails(DomainUtility.GetPrintRecipientWithNorwegianAddress(), DomainUtility.GetPrintReturnRecipientWithNorwegianAddress(), PrintColors.Colors); List <PrintInstruction> printinstruction = new List <PrintInstruction>(); printinstruction.Add(new PrintInstruction("test", "testing")); printDetails.PrintInstructions = new PrintInstructions(printinstruction); //Act //Assert Comparator.AssertEqual(DomainUtility.GetPrintRecipientWithNorwegianAddress(), printDetails.PrintRecipient); Comparator.AssertEqual(DomainUtility.GetPrintReturnRecipientWithNorwegianAddress(), printDetails.PrintReturnRecipient); Assert.Equal(PrintColors.Colors, printDetails.PrintColors); Assert.Equal(NondeliverableHandling.ReturnToSender, printDetails.NondeliverableHandling); Comparator.AssertEqual(printinstruction, printDetails.PrintInstructions); }
public void IdentificationByPinReturnsDigipostResultWithNoneResultType() { //Arrange var source = new identificationresult { result = identificationresultcode.DIGIPOST, Items = new object[] { null } //ItemsElementName = new [] { }, //IdentificationResultCode = IdentificationResultCode.Digipost, //IdentificationValue = null, //IdentificationResultType = IdentificationResultType.None }; var expected = new IdentificationResult(IdentificationResultType.DigipostAddress, string.Empty); //Act var actual = DataTransferObjectConverter.FromDataTransferObject(source); //Assert Comparator.AssertEqual(expected, actual); }
public void IdentificationByNameAndAddress() { //Arrange var source = new Identification( new RecipientByNameAndAddress("Ola Nordmann", "Osloveien 22", "0001", "Oslo") { AddressLine2 = "Adresselinje2", BirthDate = DateTime.Today, PhoneNumber = "123456789", Email = "*****@*****.**" } ); var sourceRecipient = (RecipientByNameAndAddress)source.DigipostRecipient; var expectedDto = new identification { ItemElementName = ItemChoiceType.nameandaddress, Item = new nameandaddress { fullname = sourceRecipient.FullName, addressline1 = sourceRecipient.AddressLine1, addressline2 = sourceRecipient.AddressLine2, postalcode = sourceRecipient.PostalCode, city = sourceRecipient.City, birthdate = sourceRecipient.BirthDate.Value, birthdateSpecified = true, phonenumber = sourceRecipient.PhoneNumber, emailaddress = sourceRecipient.Email } }; //Act var actualDto = DataTransferObjectConverter.ToDataTransferObject(source); //Assert Comparator.AssertEqual(expectedDto, actualDto); }
public void Error() { //Arrange var source = new error { errorcode = "UNKNOWN_RECIPIENT", errormessage = "The recipient does not have a Digipost account.", errortype = "CLIENT_DATA" }; var expected = new Error { Errorcode = source.errorcode, Errormessage = source.errormessage, Errortype = source.errortype }; //Act var actual = DataTransferObjectConverter.FromDataTransferObject(source); //Assert Comparator.AssertEqual(expected, actual); }
public void IdentificationByOrganizationNumberReturnsUnidentifiedResultWithUnidentifiedReason() { //Arrange var reason = unidentifiedreason.NOT_FOUND; var source = new identificationresult { result = identificationresultcode.UNIDENTIFIED, Items = new object[] { reason }, ItemsElementName = new[] { ItemsChoiceType.unidentifiedreason } //IdentificationResultCode = IdentificationResultCode.Unidentified, //IdentificationValue = reason, //IdentificationResultType = IdentificationResultType.UnidentifiedReason }; var expected = new IdentificationResult(IdentificationResultType.UnidentifiedReason, reason.ToString()); //Act var actual = DataTransferObjectConverter.FromDataTransferObject(source); //Assert Comparator.AssertEqual(expected, actual); }
public void IdentificationByAddressReturnsIdentifiedResultWithPersonalAliasResultType() { //Arrange const string personAlias = "fewoinf23nio3255n32oi5n32oi5n#1234"; var source = new identificationresult { result = identificationresultcode.IDENTIFIED, Items = new object[] { personAlias }, ItemsElementName = new[] { ItemsChoiceType.personalias } //IdentificationResultCode = IdentificationResultCode.Identified, //IdentificationValue = personAlias, //IdentificationResultType = IdentificationResultType.Personalias }; var expected = new IdentificationResult(IdentificationResultType.Personalias, personAlias); //Act var actual = DataTransferObjectConverter.FromDataTransferObject(source); //Assert Comparator.AssertEqual(expected, actual); }
public void IdentificationByAddressReturnsDigipostResultWithDigipostAddressResultType() { //Arrange const string digipostAddress = "ola.nordmann#1234"; var source = new identificationresult { result = identificationresultcode.DIGIPOST, Items = new object[] { digipostAddress }, ItemsElementName = new[] { ItemsChoiceType.digipostaddress } //IdentificationResultCode = IdentificationResultCode.Digipost, //IdentificationValue = digipostAddress, //IdentificationResultType = IdentificationResultType.DigipostAddress }; var expected = new IdentificationResult(IdentificationResultType.DigipostAddress, digipostAddress); //Act var actual = DataTransferObjectConverter.FromDataTransferObject(source); //Assert Comparator.AssertEqual(expected, actual); }
public void IdentificationByPinReturnsInvalidResultWithInvalidReason() { //Arrange object invalidValue = invalidreason.INVALID_PERSONAL_IDENTIFICATION_NUMBER; var source = new identificationresult { result = identificationresultcode.INVALID, Items = new[] { invalidValue }, ItemsElementName = new[] { ItemsChoiceType.invalidreason } //IdentificationResultCode = IdentificationResultCode.Invalid, //IdentificationValue = invalidValue, //IdentificationResultType = IdentificationResultType.InvalidReason }; var expected = new IdentificationResult(IdentificationResultType.InvalidReason, invalidValue.ToString()); //Act var actual = DataTransferObjectConverter.FromDataTransferObject(source); //Assert Comparator.AssertEqual(expected, actual); }
public void RecipientByNameAndAddress() { //Arrange var birthDate = DateTime.Now; var source = new RecipientByNameAndAddress("Ola Nordmann", "Biskop Gunnerus Gate 14", "0001", "Oslo") { AddressLine2 = "Etasje 15", BirthDate = birthDate, PhoneNumber = "123456789", Email = "*****@*****.**" }; var expectedDto = new messagerecipient { ItemElementName = ItemChoiceType1.nameandaddress, Item = new nameandaddress { fullname = source.FullName, addressline1 = source.AddressLine1, addressline2 = source.AddressLine2, postalcode = source.PostalCode, city = source.City, birthdate = birthDate, birthdateSpecified = true, phonenumber = source.PhoneNumber, emailaddress = source.Email } }; //Act var actualDto = DataTransferObjectConverter.ToDataTransferObject(source); //Assert Comparator.AssertEqual(expectedDto, actualDto); }
public void Document() { //Arrange IDocument source = new Document("TestSubject", "txt", new byte[2], AuthenticationLevel.Password, SensitivityLevel.Sensitive, new SmsNotification(3)); var expectedDto = new document { subject = source.Subject, filetype = source.FileType, authenticationlevel = source.AuthenticationLevel.ToAuthenticationLevel(), authenticationlevelSpecified = true, sensitivitylevel = source.SensitivityLevel.ToSensitivityLevel(), sensitivitylevelSpecified = true, smsnotification = new smsnotification { afterhours = source.SmsNotification.NotifyAfterHours.ToArray() }, uuid = source.Guid }; //Act var actualDto = SendDataTransferObjectConverter.ToDataTransferObject(source); //Assert Comparator.AssertEqual(expectedDto, actualDto); }
public void SearchResult() { //Arrange var source = new recipients { recipient = new[] { new recipient { firstname = "Stian Jarand", middlename = "Jani", lastname = "Larsen", digipostaddress = "Stian.Jani.Larsen#22DB", mobilenumber = "12345678", organisationname = "Organisatorisk Landsforbund", organisationnumber = "1234567689", address = new[] { new address { street = "Bakkeveien", housenumber = "3", houseletter = "C", additionaladdressline = "Underetasjen", zipcode = "3453", city = "Konjakken" }, new address { street = "Komleveien", housenumber = "33", zipcode = "3453", city = "Konjakken" } } }, new recipient { firstname = "Bentoni Jarandsen", lastname = "Larsen", mobilenumber = "02345638", digipostaddress = "Bentoni.Jarandsen.Larsen#KG33", address = new[] { new address { street = "Mudleveien", housenumber = "45", zipcode = "4046", city = "Hafrsfjell" } } } } }; var recipient0 = source.recipient.ElementAt(0); var recipient1 = source.recipient.ElementAt(1); var expected = new SearchDetailsResult { PersonDetails = new List <SearchDetails> { new SearchDetails { FirstName = recipient0.firstname, MiddleName = recipient0.middlename, LastName = recipient0.lastname, MobileNumber = recipient0.mobilenumber, OrganizationName = recipient0.organisationname, OrganizationNumber = recipient0.organisationnumber, DigipostAddress = recipient0.digipostaddress, SearchDetailsAddress = new List <SearchDetailsAddress> { new SearchDetailsAddress { Street = recipient0.address[0].street, HouseNumber = recipient0.address[0].housenumber, HouseLetter = recipient0.address[0].houseletter, AdditionalAddressLine = recipient0.address[0].additionaladdressline, PostalCode = recipient0.address[0].zipcode, City = recipient0.address[0].city }, new SearchDetailsAddress { Street = recipient0.address[1].street, HouseNumber = recipient0.address[1].housenumber, HouseLetter = recipient0.address[1].houseletter, AdditionalAddressLine = recipient0.address[1].additionaladdressline, PostalCode = recipient0.address[1].zipcode, City = recipient0.address[1].city } } }, new SearchDetails { FirstName = recipient1.firstname, MiddleName = recipient1.middlename, LastName = recipient1.lastname, MobileNumber = recipient1.mobilenumber, OrganizationName = recipient1.organisationname, OrganizationNumber = recipient1.organisationnumber, DigipostAddress = recipient1.digipostaddress, SearchDetailsAddress = new List <SearchDetailsAddress> { new SearchDetailsAddress { Street = recipient1.address[0].street, HouseNumber = recipient1.address[0].housenumber, HouseLetter = recipient1.address[0].houseletter, AdditionalAddressLine = recipient1.address[0].additionaladdressline, PostalCode = recipient1.address[0].zipcode, City = recipient1.address[0].city } } } } }; var actual = DataTransferObjectConverter.FromDataTransferObject(source); //Assert Comparator.AssertEqual(expected, actual); }