Esempio n. 1
0
        public NameOnlyParameter(Name name)
        {
            if (name == null)
                throw new ArgumentNullException(nameof(name));

            this.Name = name;
        }
Esempio n. 2
0
        public void SutCanReadAndWriteJsonName(NameJsonConverter sut, Name aName)
        {
            var serializer = new JsonSerializer();
            serializer.Converters.Add(sut);
            var stringWriter = new StringWriter();
            var jsonWriter = new JsonTextWriter(stringWriter);
            serializer.Serialize(jsonWriter, aName);

            var name = serializer.Deserialize<Name>(new JsonTextReader(new StringReader(stringWriter.ToString())));
            Assert.Equal(aName, name);
        }
        public NameOnlyParameterViewModel(Name name, Name displayName)
        {
            if (name == null)
                throw new ArgumentNullException(nameof(name));

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

            this.Name = name;
            this.DisplayName = displayName;
        }
Esempio n. 4
0
        public NameValueParameter(Name name, string value)
        {
            if (name == null)
                throw new ArgumentNullException(nameof(name));

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

            this.Name = name;
            this.Value = value;
        }
        public void CreateWithValidParametersReturnsViewModel(
            Name name,
            Name anotherName,
            IChannel<SaveCmdApplicationConfigurationCommand> channel,
            CmdApplicationConfigurationViewModelFactory sut)
        {
            var viewModel = sut.Create(TestCmdApplicationMeta.Application);
            Assert.Equal(TestCmdApplicationMeta.Application.ApplicationName, viewModel.ApplicationName);
            foreach (var meta in TestCmdApplicationMeta.Application.ParameterMetas)
            {
                viewModel.Properties.Any(a => a.GetParameterType() == meta.ParameterType);
            }

        }
 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 CmdApplicationConfiguration(Name name, Name applicationName, ReadOnlyCollection<IParameter> parameters)
        {
            if (name == null)
                throw new ArgumentNullException(nameof(name));

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

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

            this.Name = name;
            this.ApplicationName = applicationName;
            this.Parameters = parameters;
        }
Esempio n. 8
0
        public CmdApplicationMeta(Name friendlyName, Name applicationName, IEnumerable<ParameterMeta> parameterMetas)
        {
            if (friendlyName == null)
                throw new ArgumentNullException(nameof(friendlyName));

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

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

            this.FriendlyName = friendlyName;
            this.ApplicationName = applicationName;
            this.ParameterMetas = new ReadOnlyCollection<ParameterMeta>(new List<ParameterMeta>(parameterMetas));
        }
 public void CreateWithInvalidParameterMetaTypeThrowsException(
     Name name,
     Name applicationName,
     Name parameterName,
     IChannel<SaveCmdApplicationConfigurationCommand> channel,
     CmdApplicationConfigurationViewModelFactory sut)
 {
     var parameter = new Mock<IParameter>();
     var meta = new CmdApplicationMeta(
         name,
         applicationName,
         new List<ParameterMeta>()
         {
             ParameterMeta.Create<IParameter>(parameterName)
         });
     Assert.Throws<ArgumentException>(() => sut.Create(meta));
 }
 public void CtorParametersAreInitialized(IFixture fixture, Name name)
 {
     var assertion = new ConstructorInitializedMemberAssertion(fixture);
     assertion.Verify(typeof(CmdApplicationConfigurationViewModel).GetConstructors());
 }
 public void PopulateFromCmdConfigurationWithDifferentApplicationDoesNothing(
     IFixture fixture,
     Name applicationName,
     List<NameOnlyParameterViewModel> properties)
 {
     var sut = fixture.WithConstructorParameters(new Dictionary<string, object>()
     {
         {nameof(applicationName), applicationName},
         {nameof(properties), properties.Cast<ParameterViewModel>().ToList() }
     }).Create<CmdApplicationConfigurationViewModel>();
 }
 public void SutWithoutDisplayNameReturnsEmptyDisplayName(Name aName)
 {
     var sut = new NameOnlyParameterViewModel(aName);
     Assert.Equal(Name.EmptyName, sut.DisplayName);
 }
 public NameOnlyParameterViewModel(Name name) : this(name, Name.EmptyName)
 {
 }
 public NameValueParameterViewModel(Name name) : this(name, Name.EmptyName)
 {
 }
 private static string FormatFriendlyName(Name name)
 {
     var spaceReplace = "_";
     return name.ToString().Replace(" ", spaceReplace);
 }