public void GetCmdApplicationConfigurationReturnsEmptyIfFriendlyNameIsEmpty(CmdApplicationConfigurationViewModel sut)
        {
            sut.FriendlyName = string.Empty;
            var actual = sut.GetCmdApplicationConfiguration();

            Assert.Equal(Maybe.Empty <CmdApplicationConfiguration>(), actual);
        }
 public void OnSuccesfullSaveSwtichesToReadMode(CmdApplicationConfigurationViewModel sut)
 {
     sut.ToggleEdit.Execute(null);
     Assert.True(sut.IsInEditMode);
     DomainEvents.Publish(new ConfigurationSavedEvent(Guid.NewGuid()));
     Assert.False(sut.IsInEditMode);
 }
 public void GetCmdApplicationConfigurationReturnsEmptyIfNoneOfTheParameterHasValue(
     CmdApplicationConfigurationViewModel sut)
 {
     Assert.True(!string.IsNullOrEmpty(sut.FriendlyName));
     Assert.False(sut.Properties.Any(a => a.GetParameter().Any()));
     var actual = sut.GetCmdApplicationConfiguration();
     Assert.False(actual.Any());
 }
        public void GetCmdApplicationConfigurationReturnsEmptyIfNoneOfTheParameterHasValue(
            CmdApplicationConfigurationViewModel sut)
        {
            Assert.True(!string.IsNullOrEmpty(sut.FriendlyName));
            Assert.False(sut.Properties.Any(a => a.GetParameter().Any()));
            var actual = sut.GetCmdApplicationConfiguration();

            Assert.False(actual.Any());
        }
예제 #5
0
 public void OnAddNewConfigurationSelectedItemIsSetToNewItem(
     [Frozen] Mock <ICmdApplicationConfigurationViewModelFactory> mockFactory,
     IChannel <SaveCmdApplicationConfigurationCommand> channel,
     CmdApplicationConfigurationViewModel expected,
     CmdApplicationConfigurationListViewModel sut,
     AddCmdApplicationConfigurationEvent eventMessage)
 {
     SetUpFactoryToReturnANewInstance(expected, mockFactory);
     sut.OnAddCmdApplicationConfigurationEvent(eventMessage);
     Assert.Equal(expected, sut.SelectedConfiguration);
 }
 public void OnAddNewConfigurationSelectedItemIsSetToNewItem(
     [Frozen]Mock<ICmdApplicationConfigurationViewModelFactory> mockFactory,
     IChannel<SaveCmdApplicationConfigurationCommand> channel,
     CmdApplicationConfigurationViewModel expected,
     CmdApplicationConfigurationListViewModel sut,
     AddCmdApplicationConfigurationEvent eventMessage)
 {
     SetUpFactoryToReturnANewInstance(expected, mockFactory);
     sut.OnAddCmdApplicationConfigurationEvent(eventMessage);
     Assert.Equal(expected, sut.SelectedConfiguration);
 }
        public void GetCmdApplicationConfigurationReturnsConfigurationIfAtleastOneParameterHasValue(
            CmdApplicationConfigurationViewModel sut)
        {
            Assert.True(!string.IsNullOrEmpty(sut.FriendlyName));

            var vm = new NameOnlyParameterViewModel((Name)"testParameter");
            vm.IsSelected = true;
            sut.Properties.Add(vm);

            var actual = sut.GetCmdApplicationConfiguration();
            Assert.True(actual.Any());
        }
        public void GetCmdApplicationConfigurationReturnsConfigurationIfAtleastOneParameterHasValue(
            CmdApplicationConfigurationViewModel sut)
        {
            Assert.True(!string.IsNullOrEmpty(sut.FriendlyName));

            var vm = new NameOnlyParameterViewModel((Name)"testParameter");

            vm.IsSelected = true;
            sut.Properties.Add(vm);

            var actual = sut.GetCmdApplicationConfiguration();

            Assert.True(actual.Any());
        }
        public void SaveCmdApplicationConfigurationCommandNotSendWhenViewModelIsInInvalidState(
            [Frozen] Mock <IChannel <SaveCmdApplicationConfigurationCommand> > channel,
            CmdApplicationConfigurationViewModel sut)
        {
            sut.ToggleEdit.Execute(null);
            sut.FriendlyName = string.Empty;
            sut.Save.Execute(null);
            channel.Verify(a => a.Send(It.IsAny <SaveCmdApplicationConfigurationCommand>()), Times.Never());

            sut.FriendlyName = "Valid Friendly Name";
            Assert.False(sut.Properties.Any(a => a.GetParameter().Any()));
            sut.Save.Execute(null);
            channel.Verify(a => a.Send(It.IsAny <SaveCmdApplicationConfigurationCommand>()), Times.Never());
        }
 public void SutSubscribesToAddCmdApplicationConfigurationEvent(
     Name aName,
     IChannel<SaveCmdApplicationConfigurationCommand> channel,
     CmdApplicationConfigurationViewModel vm,
     [Frozen]Mock<ICmdApplicationConfigurationViewModelFactory> mockFactory,
     Messenger messenger,
     IFixture fixture)
 {
     fixture.Inject<IMessenger>(messenger);
     var sut = fixture.Create<CmdApplicationConfigurationListViewModel>();
     SetUpFactoryToReturnANewInstance(vm, mockFactory);
     var expected = sut.ApplicationConfigurations.Count + 1;
     messenger.Send(new AddCmdApplicationConfigurationEvent());
     Assert.Equal(expected, sut.ApplicationConfigurations.Count);
 }
예제 #11
0
        public void SutSubscribesToAddCmdApplicationConfigurationEvent(
            Name aName,
            IChannel <SaveCmdApplicationConfigurationCommand> channel,
            CmdApplicationConfigurationViewModel vm,
            [Frozen] Mock <ICmdApplicationConfigurationViewModelFactory> mockFactory,
            Messenger messenger,
            IFixture fixture)
        {
            fixture.Inject <IMessenger>(messenger);
            var sut = fixture.Create <CmdApplicationConfigurationListViewModel>();

            SetUpFactoryToReturnANewInstance(vm, mockFactory);
            var expected = sut.ApplicationConfigurations.Count + 1;

            messenger.Send(new AddCmdApplicationConfigurationEvent());
            Assert.Equal(expected, sut.ApplicationConfigurations.Count);
        }
        public void SaveCmdApplicationConfigurationCommandSendWhenViewModelIsInValidState(
            [Frozen] Mock <IChannel <SaveCmdApplicationConfigurationCommand> > channel,
            CmdApplicationConfigurationViewModel sut)
        {
            sut.ToggleEdit.Execute(null);
            sut.FriendlyName = "Valid Friendly Name";
            var vm = new NameOnlyParameterViewModel((Name)"testParameter");

            vm.IsSelected = true;
            sut.Properties.Add(vm);

            sut.Save.Execute(null);

            channel.Verify(m => m.Send(It.Is <SaveCmdApplicationConfigurationCommand>(a =>
                                                                                      a.ApplicationConfiguration.ApplicationName == sut.ApplicationName &&
                                                                                      a.ApplicationConfiguration.Name == (Name)sut.FriendlyName &&
                                                                                      a.ApplicationConfiguration.Parameters.Count == 1)), Times.Once());
        }
 public void SaveCommandDisabledWhenNotInEditMode(CmdApplicationConfigurationViewModel sut)
 {
     Assert.False(sut.IsInEditMode);
     Assert.False(sut.Save.CanExecute(null));
 }
 public void EnsureCommandsAreAllSetUpOnSutConstruction(CmdApplicationConfigurationViewModel sut)
 {
     sut.EnsureCommandsAreAllSetUpOnSutConstruction();
 }
 public void GetCmdApplicationConfigurationReturnsEmptyIfFriendlyNameIsEmpty(CmdApplicationConfigurationViewModel sut)
 {
     sut.FriendlyName = string.Empty;
     var actual = sut.GetCmdApplicationConfiguration();
     Assert.Equal(Maybe.Empty<CmdApplicationConfiguration>(), actual);
 }
 public void PopulateFromCmdConfigurationWithNullApplicationThrowsException(CmdApplicationConfigurationViewModel sut)
 {
     sut.PopulateFromCmdApplicationConfiguration(null);
 }
 public void EnsureCommandsAreAllSetUpOnSutConstruction(CmdApplicationConfigurationViewModel sut)
 {
     sut.EnsureCommandsAreAllSetUpOnSutConstruction();
 }
 public void SutHasSaveCommandInitialized(CmdApplicationConfigurationViewModel sut)
 {
     Assert.NotNull(sut.Save);
 }
        public void SaveCmdApplicationConfigurationCommandSendWhenViewModelIsInValidState(
            [Frozen]Mock<IChannel<SaveCmdApplicationConfigurationCommand>> channel,
            CmdApplicationConfigurationViewModel sut)
        {
            sut.ToggleEdit.Execute(null);
            sut.FriendlyName = "Valid Friendly Name";
            var vm = new NameOnlyParameterViewModel((Name)"testParameter");
            vm.IsSelected = true;
            sut.Properties.Add(vm);

            sut.Save.Execute(null);

            channel.Verify(m => m.Send(It.Is<SaveCmdApplicationConfigurationCommand>(a =>
           a.ApplicationConfiguration.ApplicationName == sut.ApplicationName &&
           a.ApplicationConfiguration.Name == (Name)sut.FriendlyName &&
           a.ApplicationConfiguration.Parameters.Count == 1)), Times.Once());
        }
 public void PopulateFromCmdConfigurationWithNullApplicationThrowsException(CmdApplicationConfigurationViewModel sut)
 {
     sut.PopulateFromCmdApplicationConfiguration(null);
 }
 public void SaveCommandEnabledWhenInEditMode(CmdApplicationConfigurationViewModel sut)
 {
     Assert.False(sut.IsInEditMode);
     sut.ToggleEdit.Execute(null);
     Assert.True(sut.Save.CanExecute(null));
 }
        public void SaveCmdApplicationConfigurationCommandNotSendWhenViewModelIsInInvalidState(
            [Frozen]Mock<IChannel<SaveCmdApplicationConfigurationCommand>> channel,
            CmdApplicationConfigurationViewModel sut)
        {
            sut.ToggleEdit.Execute(null);
            sut.FriendlyName = string.Empty;
            sut.Save.Execute(null);
            channel.Verify(a => a.Send(It.IsAny<SaveCmdApplicationConfigurationCommand>()), Times.Never());

            sut.FriendlyName = "Valid Friendly Name";
            Assert.False(sut.Properties.Any(a => a.GetParameter().Any()));
            sut.Save.Execute(null);
            channel.Verify(a => a.Send(It.IsAny<SaveCmdApplicationConfigurationCommand>()), Times.Never());
        }
 private void SetUpFactoryToReturnANewInstance(
     CmdApplicationConfigurationViewModel vm,
     Mock<ICmdApplicationConfigurationViewModelFactory> mockFactory)
 {
     mockFactory.Setup(a => a.Create(It.IsAny<CmdApplicationMeta>())).Returns(vm);
 }
 public void SutIsViewModelBase(CmdApplicationConfigurationViewModel sut)
 {
     Assert.IsAssignableFrom <ViewModelBase>(sut);
 }
 public void SutHasSaveCommandInitialized(CmdApplicationConfigurationViewModel sut)
 {
     Assert.NotNull(sut.Save);
 }
 public void OnSuccesfullSaveSwtichesToReadMode(CmdApplicationConfigurationViewModel sut)
 {
     sut.ToggleEdit.Execute(null);
     Assert.True(sut.IsInEditMode);
     DomainEvents.Publish(new ConfigurationSavedEvent(Guid.NewGuid()));
     Assert.False(sut.IsInEditMode);
 }
 public void SutIsViewModelBase(CmdApplicationConfigurationViewModel sut)
 {
     Assert.IsAssignableFrom<ViewModelBase>(sut);
 }
 public void ToggleEditTogglesIsInEditMode(CmdApplicationConfigurationViewModel sut)
 {
     Assert.False(sut.IsInEditMode);
     sut.ToggleEdit.Execute(null);
     Assert.True(sut.IsInEditMode);
 }
 public void SaveCommandDisabledWhenNotInEditMode(CmdApplicationConfigurationViewModel sut)
 {
     Assert.False(sut.IsInEditMode);
     Assert.False(sut.Save.CanExecute(null));
 }
예제 #30
0
 private void SetUpFactoryToReturnANewInstance(
     CmdApplicationConfigurationViewModel vm,
     Mock <ICmdApplicationConfigurationViewModelFactory> mockFactory)
 {
     mockFactory.Setup(a => a.Create(It.IsAny <CmdApplicationMeta>())).Returns(vm);
 }
 public void SaveCommandEnabledWhenInEditMode(CmdApplicationConfigurationViewModel sut)
 {
     Assert.False(sut.IsInEditMode);
     sut.ToggleEdit.Execute(null);
     Assert.True(sut.Save.CanExecute(null));
 }
        public CmdApplicationConfigurationViewModel Create(
            CmdApplicationConfiguration applicationConfiguration,
            CmdApplicationMeta applicationMeta)
        {
            if (applicationConfiguration == null)
                throw new ArgumentNullException(nameof(applicationConfiguration));

            if (applicationMeta == null)
                throw new ArgumentNullException(nameof(applicationMeta));

            var properties = new List<ParameterViewModel>();
            foreach (var parameterMeta in applicationMeta.ParameterMetas)
            {
                ParameterViewModel viewModel = null;
                if (parameterMeta.ParameterType == typeof(NameValueParameter))
                {
                    viewModel = new NameValueParameterViewModel(parameterMeta.Name, parameterMeta.DisplayName);
                    viewModel.WithParameter(applicationConfiguration
                         .Parameters
                         .FirstOrDefault(a => a.Name == parameterMeta.Name));
                }
                else if (parameterMeta.ParameterType == typeof(NameOnlyParameter))
                {
                    viewModel = new NameOnlyParameterViewModel(parameterMeta.Name, parameterMeta.DisplayName);
                    viewModel.WithParameter(applicationConfiguration.Parameters.FirstOrDefault(a => a.Name == parameterMeta.Name));
                }
                else
                {
                    throw new ArgumentException(string.Format("Type {0} not supported for parameter {1}", parameterMeta.ParameterType, parameterMeta.Name));
                }

                properties.Add(viewModel);
            }
            var returnValue = new CmdApplicationConfigurationViewModel(
                applicationMeta,
                properties,
                Channel,
                StringParsers);
            returnValue.FriendlyName = (string)applicationConfiguration.Name;
            return returnValue;
        }
 public void ToggleEditTogglesIsInEditMode(CmdApplicationConfigurationViewModel sut)
 {
     Assert.False(sut.IsInEditMode);
     sut.ToggleEdit.Execute(null);
     Assert.True(sut.IsInEditMode);
 }