public void MapToTrickleOverTimePeriodWithCountryCodeReplacement() { var model = new CoordinatedSharedMessageModel { Numbers = "04040404040, 11111111111", Message = "Message", StartTime = DateTime.Now.AddHours(2), SendAllBy = DateTime.Now.AddHours(3), Tags = "tag1, tag2", Topic = "Dance Dance Revolution!", ConfirmationEmail = "*****@*****.**" }; var mapper = new CoordinatorModelToMessageMapping(); var message = mapper.MapToTrickleOverPeriod(model, new CountryCodeReplacement { CountryCode = "+61", LeadingNumberToReplace = "0"}); var coordinationDuration = model.SendAllBy.Value.Subtract(model.StartTime); Assert.That(coordinationDuration, Is.GreaterThan(new TimeSpan(0))); Assert.That(message.Messages.Count, Is.EqualTo(2)); Assert.That(message.Messages[0].Mobile, Is.EqualTo("+614040404040")); Assert.That(message.Messages[0].Message, Is.EqualTo(model.Message)); Assert.That(message.Messages[1].Mobile, Is.EqualTo(model.Numbers.Split(',')[1].Trim())); Assert.That(message.Messages[1].Message, Is.EqualTo(model.Message)); Assert.That(message.MetaData.Tags, Is.EqualTo(model.Tags.Split(',').ToList().Select(t => t.Trim().ToList()))); Assert.That(message.MetaData.Topic, Is.EqualTo(model.Topic)); Assert.That(message.StartTimeUtc, Is.EqualTo(model.StartTime.ToUniversalTime())); Assert.That(message.Duration, Is.EqualTo(coordinationDuration)); Assert.That(message.ConfirmationEmail, Is.EqualTo(model.ConfirmationEmail)); }
public void MapToSendAllAtOnce() { var model = new CoordinatedSharedMessageModel { Numbers = "04040404040, 11111111111", Message = "Message", StartTime = DateTime.Now.AddHours(2), SendAllAtOnce = true, Tags = "tag1, tag2", Topic = "Dance Dance Revolution!", ConfirmationEmail = "confirmation, two", UserTimeZone = "Australia/Sydney" }; var mappedDateTime = DateTime.Now; var olsenMapping = MockRepository.GenerateMock<IDateTimeUtcFromOlsenMapping>(); olsenMapping.Expect(o => o.DateTimeWithOlsenZoneToUtc(model.StartTime, model.UserTimeZone)).Return(mappedDateTime); var mapper = new CoordinatorModelToMessageMapping(olsenMapping); var message = mapper.MapToSendAllAtOnce(model, new CountryCodeReplacement(), new List<string>()); Assert.That(message.Messages.Count, Is.EqualTo(2)); Assert.That(message.Messages[0].Mobile, Is.EqualTo(model.Numbers.Split(',')[0].Trim())); Assert.That(message.Messages[0].Message, Is.EqualTo(model.Message)); Assert.That(message.Messages[1].Mobile, Is.EqualTo(model.Numbers.Split(',')[1].Trim())); Assert.That(message.Messages[1].Message, Is.EqualTo(model.Message)); Assert.That(message.MetaData.Tags, Is.EqualTo(model.Tags.Split(',').ToList().Select(t => t.Trim()).ToList())); Assert.That(message.MetaData.Topic, Is.EqualTo(model.Topic)); Assert.That(message.SendTimeUtc, Is.EqualTo(mappedDateTime)); Assert.That(message.ConfirmationEmail, Is.EqualTo(model.ConfirmationEmail)); Assert.That(message.ConfirmationEmails.Count, Is.EqualTo(2)); Assert.That(message.ConfirmationEmails[0], Is.EqualTo("confirmation")); Assert.That(message.ConfirmationEmails[1], Is.EqualTo("two")); Assert.That(message.UserOlsenTimeZone, Is.EqualTo(model.UserTimeZone)); }
public void MapToTrickleSpacedByTimePeriodWithCountryCodeReplacement() { var model = new CoordinatedSharedMessageModel { Numbers = "04040404040, 11111111111", Message = "Message", StartTime = DateTime.Now.AddHours(2), TimeSeparatorSeconds = 90, Tags = "tag1, tag2", Topic = "Dance Dance Revolution!", ConfirmationEmail = "confirmation" }; var mapper = new CoordinatorModelToMessageMapping(); var message = mapper.MapToTrickleSpacedByPeriod(model, new CountryCodeReplacement { CountryCode = "+61", LeadingNumberToReplace = "0"}); Assert.That(message.Messages.Count, Is.EqualTo(2)); Assert.That(message.Messages[0].Mobile, Is.EqualTo("+614040404040")); Assert.That(message.Messages[0].Message, Is.EqualTo(model.Message)); Assert.That(message.Messages[1].Mobile, Is.EqualTo(model.Numbers.Split(',')[1].Trim())); Assert.That(message.Messages[1].Message, Is.EqualTo(model.Message)); Assert.That(message.MetaData.Tags, Is.EqualTo(model.Tags.Split(',').ToList().Select(t => t.Trim()).ToList())); Assert.That(message.MetaData.Topic, Is.EqualTo(model.Topic)); Assert.That(message.StartTimeUtc, Is.EqualTo(model.StartTime.ToUniversalTime())); Assert.That(message.TimeSpacing, Is.EqualTo(TimeSpan.FromSeconds(model.TimeSeparatorSeconds.Value))); Assert.That(message.ConfirmationEmail, Is.EqualTo(model.ConfirmationEmail)); }
public void MapToTrickleOverTimePeriodRemovingExcludedNumbers() { var model = new CoordinatedSharedMessageModel { Numbers = "04040404040, 11111111111", Message = "Message", StartTime = DateTime.Now.AddHours(2), SendAllBy = DateTime.Now.AddHours(3), Topic = "Dance Dance Revolution!", ConfirmationEmail = "*****@*****.**", UserTimeZone = "Australia/Sydney" }; var mappedDateTime = DateTime.Now; var olsenMapping = MockRepository.GenerateMock<IDateTimeUtcFromOlsenMapping>(); olsenMapping.Expect(o => o.DateTimeWithOlsenZoneToUtc(model.StartTime, model.UserTimeZone)).Return(mappedDateTime); var mapper = new CoordinatorModelToMessageMapping(olsenMapping); var excludedNumbers = new List<string> { "04040404040" }; var message = mapper.MapToTrickleOverPeriod(model, new CountryCodeReplacement(), excludedNumbers); var coordinationDuration = model.SendAllBy.Value.Subtract(model.StartTime); Assert.That(coordinationDuration, Is.GreaterThan(new TimeSpan(0))); Assert.That(message.Messages.Count, Is.EqualTo(1)); Assert.That(message.Messages[0].Mobile, Is.EqualTo(model.Numbers.Split(',')[1].Trim())); Assert.That(message.Messages[0].Message, Is.EqualTo(model.Message)); Assert.That(message.MetaData.Tags, Is.EqualTo(null)); Assert.That(message.MetaData.Topic, Is.EqualTo(model.Topic)); Assert.That(message.StartTimeUtc, Is.EqualTo(mappedDateTime)); Assert.That(message.Duration, Is.EqualTo(coordinationDuration)); Assert.That(message.ConfirmationEmail, Is.EqualTo(model.ConfirmationEmail)); }
public void MapToTrickleSpacedByTimePeriodWithCountryCodeReplacement() { var model = new CoordinatedSharedMessageModel { Numbers = "04040404040, 11111111111", Message = "Message", StartTime = DateTime.Now.AddHours(2), TimeSeparatorSeconds = 90, Tags = "tag1, tag2", Topic = "Dance Dance Revolution!", ConfirmationEmail = "confirmation, anotherone; yetanother: more", UserTimeZone = "Australia/Sydney" }; var mappedDateTime = DateTime.Now; var olsenMapping = MockRepository.GenerateMock<IDateTimeUtcFromOlsenMapping>(); olsenMapping.Expect(o => o.DateTimeWithOlsenZoneToUtc(model.StartTime, model.UserTimeZone)).Return(mappedDateTime); var mapper = new CoordinatorModelToMessageMapping(olsenMapping); var message = mapper.MapToTrickleSpacedByPeriod(model, new CountryCodeReplacement { CountryCode = "+61", LeadingNumberToReplace = "0"}, new List<string>()); Assert.That(message.Messages.Count, Is.EqualTo(2)); Assert.That(message.Messages[0].Mobile, Is.EqualTo("+614040404040")); Assert.That(message.Messages[0].Message, Is.EqualTo(model.Message)); Assert.That(message.Messages[1].Mobile, Is.EqualTo(model.Numbers.Split(',')[1].Trim())); Assert.That(message.Messages[1].Message, Is.EqualTo(model.Message)); Assert.That(message.MetaData.Tags, Is.EqualTo(model.Tags.Split(',').ToList().Select(t => t.Trim()).ToList())); Assert.That(message.MetaData.Topic, Is.EqualTo(model.Topic)); Assert.That(message.StartTimeUtc, Is.EqualTo(mappedDateTime)); Assert.That(message.TimeSpacing, Is.EqualTo(TimeSpan.FromSeconds(model.TimeSeparatorSeconds.Value))); Assert.That(message.ConfirmationEmail, Is.EqualTo(model.ConfirmationEmail)); Assert.That(message.ConfirmationEmails.Count, Is.EqualTo(4)); Assert.That(message.ConfirmationEmails[0], Is.EqualTo("confirmation")); Assert.That(message.ConfirmationEmails[1], Is.EqualTo("anotherone")); Assert.That(message.ConfirmationEmails[2], Is.EqualTo("yetanother")); Assert.That(message.ConfirmationEmails[3], Is.EqualTo("more")); }