public void SelectedActionProperty() { // arrange const string Subject = "Test Subject"; const string Message = "Test Message"; const string Email1 = "*****@*****.**"; const string Email2 = "*****@*****.**"; const string Email3 = "*****@*****.**"; var actionGuid = new Guid("EB8CCBA8-5903-4AB4-9CD4-192E7790B68D"); var actionBuilder = new ApprovalActionDefinition.Builder { Guid = actionGuid, SubjectTemplate = new ActionSubjectTemplate("x"), MessageTemplate = new ActionMessageTemplate("y") }; var selectedAction = actionBuilder.Build(); var dynamicManagerMock = Mock.Create<IDynamicTypeManager>(); var logger = Mock.Create<ILogger>(Behavior.Loose); var popupFactory = Mock.Create<PopupFactory>(Behavior.Loose); var windowManager = Mock.Create<IShell>(Behavior.Loose); var editableRoot = new RootStub { Id = 1, ProcessName = "AnyProcessName" }; var command = Mock.Create<IGetActionInfoCommand>(Behavior.Loose); var commandResult = Mock.Create<IGetActionInfoResult>(Behavior.Loose); Mock.Arrange(() => commandResult.Subject).Returns(Subject); Mock.Arrange(() => commandResult.Message).Returns(Message); Mock.Arrange(() => commandResult.EmailList).Returns(new[] { Email1, Email2, Email3 }); Mock.Arrange(() => command.ExecuteAsync(actionGuid, editableRoot)).Returns(TaskHelper.FromResult(commandResult)); var eventAggregator = Mock.Create<IEventAggregator>(Behavior.Loose); var vm = new EmailViewModel { EventAggregator = eventAggregator, DynamicManager = dynamicManagerMock, Logger = logger, ThePopupFactory = new Lazy<PopupFactory>(() => popupFactory), WindowManager = new Lazy<IShell>(() => windowManager), GetActionInfoCommand = command }; vm.Init(editableRoot); vm.SelectedAction = selectedAction; // assert Assert.AreEqual(Subject, vm.Subject); Assert.AreEqual(Message, vm.HtmlContent); // assert getter Assert.AreEqual(selectedAction, vm.SelectedAction); Mock.Assert(() => logger.Log(LogSeverity.Error, Arg.AnyString, Arg.IsAny<Exception>()), Occurs.Never()); Mock.Assert(() => popupFactory.NotifyFailure(Arg.IsAny<Exception>(), Arg.AnyString, Arg.AnyBool), Occurs.Never()); }
public ActionManagerStub() { var actionBuilder = new ApprovalActionDefinition.Builder { Name = "This is action name", SubjectTemplate = new ActionSubjectTemplate("This is action subject") }; ActionDefinitions = new ReadOnlyCollection<IActionDefinition>(new IActionDefinition[] { actionBuilder.Build() }); }