public void WhenIUseEditableScreenSimpleObjectViewModel() { var simpleModel = new SimpleEditableModel(); _simpleScenarioDataStore.Model = simpleModel; var mockMessageService = new FakeMessageService(); _simpleScenarioDataStore.MockMessageService = mockMessageService; var screenObjectViewModel = new TestEditableScreenSimpleObjectViewModel(mockMessageService, simpleModel); screenObjectViewModel.PropertyChanged += (sender, args) => { switch (args.PropertyName) { case "IsDirty": _simpleScenarioDataStore.WasDirtyRaised = true; break; case "CanCancelChanges": _simpleScenarioDataStore.WasCancelChangesRaised = true; break; } }; _simpleScenarioDataStore.SystemUnderTest = screenObjectViewModel; _commonScenarioDataStore.RootObject.ActivateItem(screenObjectViewModel); }
public void WhenIUseEditableScreenCompositeObjectViewModel() { var initialPhones = new[] { 546, 432 }; var compositeModel = new CompositeEditableModel("Here", initialPhones); _compositeScenarioDataStore.Model = compositeModel; var mockMessageService = new FakeMessageService(); _compositeScenarioDataStore.MockMessageService = mockMessageService; var screenObjectViewModel = new TestEditableScreenCompositeObjectViewModel(mockMessageService, compositeModel); _compositeScenarioDataStore.SystemUnderTest = screenObjectViewModel; _commonScenarioDataStore.RootObject.ActivateItem(screenObjectViewModel); }
public void HourlyMaintenanceTest() { FakeMessageService messageMock = new FakeMessageService(); //Create reminder with unknown email address at first string emailAddress = Guid.NewGuid().ToString() + "@gmx.de"; ReminderModel reminder = GetReminder(emailAddress); var homeController = new HomeController(messageMock); homeController.CreateReminder(reminder); //Verify that no reminder mail has been sent Assert.That(messageMock.ReminderEmailsSentCount, Is.EqualTo(0)); //Insert a remindii directly into the database int mailID = _db.GetEmailID(emailAddress); _db.AddReminder(reminder, mailID, DateTime.Now.AddDays(-1)); //Run hourly maintenance and check that no mail is sent out (email not verified yet) var maintenanceController = new MaintenanceController(messageMock); Assert.That(messageMock.ReminderEmailsSentCount, Is.EqualTo(0)); //Verify user new VerificationController().VerifyMailAddress(messageMock.SentVerificationCode); //Run hourly maintenance and no the reminder should be sent out new MaintenanceController(messageMock).Hourly("1234"); Assert.That(messageMock.ReminderEmailsSentCount, Is.EqualTo(1)); Assert.That(messageMock.SentoutReminder.EmailAddress, Is.EqualTo(emailAddress)); Assert.That(messageMock.SentoutReminder.Name, Is.EqualTo(reminder.Name)); //run hourly again and verify that no other reminder will be sent out new MaintenanceController(messageMock).Hourly("1234"); Assert.That(messageMock.ReminderEmailsSentCount, Is.EqualTo(1)); }
public void CreateReminder() { ReminderModel reminder = new ReminderModel() { Day = 7, Month = 6, Email = Guid.NewGuid().ToString() + "@gmx.de", Name = "Patrick Epstein", Password = "******", TimeZoneOffset = -2 }; //Create reminder with unknown email address FakeMessageService messageService = new FakeMessageService(); HomeController controller = new HomeController(messageService); var controllerResult = controller.CreateReminder(reminder) as ViewResult; //Verify Controller Result Assert.That(controllerResult.ViewName == "Success"); Assert.That((bool)controllerResult.ViewData["EmailVerified"], Is.False); //Assert verification email sent Assert.That(messageService.IsVerificationEmailSent(), Is.True); string verificationCode = messageService.SentVerificationCode; Assert.False(string.IsNullOrEmpty(verificationCode)); Assert.That(messageService.VerificationEmailsSentCount, Is.EqualTo(1)); //Try to create another reminder, same mail address still not verfied reminder.Name = "Heinz Erhardt"; reminder.Day = 14; reminder.Month = 4; controllerResult = controller.CreateReminder(reminder) as ViewResult; //Verify Controller Result Assert.That(controllerResult.ViewName == "Success"); Assert.That((bool)controllerResult.ViewData["EmailVerified"], Is.False); //Verify no new email was sent out Assert.That(messageService.VerificationEmailsSentCount, Is.EqualTo(1)); //Try to verify email address (emulate link clicking in email) VerificationController verificationController = new VerificationController(); controllerResult = verificationController.VerifyMailAddress(verificationCode) as ViewResult; //Verify Controller Result Assert.True((bool)controllerResult.ViewData["VerificationSuccess"]); //Try to create another reminder, same mail address and now also verfied reminder.Name = "Karl Gustav"; reminder.Day = 18; reminder.Month = 2; controllerResult = controller.CreateReminder(reminder) as ViewResult; //Verify Controller Result Assert.That(controllerResult.ViewName == "Success"); Assert.That((bool)controllerResult.ViewData["EmailVerified"], Is.True); //Verify no new email was sent out Assert.That(messageService.VerificationEmailsSentCount, Is.EqualTo(1)); }