private static FeatureCommandsCollection CreateCommandsImpl(IEnumerable <IISFeature> features, CommandOptions commandOptions) { var commands = new FeatureCommandsCollection(); try { bool internetInformationServerIsPresent = RegistryOperations.CheckMachineKey(@"SOFTWARE\Microsoft\InetStp"); if (!internetInformationServerIsPresent) { // IIS not installed > :-( Begin installation commands.Add(FeatureCommand.Create("IIS-DefaultDocument", "All")); } commands.InternetInformationServerIsPresent = internetInformationServerIsPresent; // IIS installed // > Enable All Features > Install foreach (IISFeature feature in features) { commands.Add(FeatureCommand.Create(feature, options: commandOptions)); } return(commands); } catch { return(commands); } }
public void Validate_Should_Throw_Exception_When_ReadRepository_Is_Null() { FeatureCommand command = FeatureCommandHandlerTestHelper.GetCommand(); this.read = null; FeatureCommandHandlerHelper.Validate(command, this.write, this.read); }
/// <summary> /// Returns test service instance. /// </summary> private IFeatureCommand GetCommand(bool initialize = true) { var feature = new FeatureCommand(_logMock.Object, _menuCommandServiceMock.Object, _messageServiceMock.Object, _utilsServiceMock.Object); if (initialize) { feature.Initialize(_featureMock.Object, 123); } return(feature); }
public void Validate_Should_Not_Add_Feature_With_Invalid_Name_Length() { FeatureCommand command = FeatureCommandHandlerTestHelper.GetCommand("a".PadLeft(101, 'a'), null, null); string expectedInvalid = string.Format(MessagesModel.MaxLength, "100"); FeatureCommandResult result = FeatureCommandHandlerHelper.Validate(command, this.write, this.read); Assert.IsFalse(result.Valid); Assert.AreEqual(expectedInvalid, result.InvalidName); }
public void Validate_Should_Not_Add_Feature_With_No_Name() { FeatureCommand command = FeatureCommandHandlerTestHelper.GetCommand(""); string expectedInvalid = MessagesModel.Required; FeatureCommandResult result = FeatureCommandHandlerHelper.Validate(command, this.write, this.read); Assert.IsFalse(result.Valid); Assert.AreEqual(expectedInvalid, result.InvalidName); }
public void PushCommand(string deviceId, FeatureCommand command) { ConcurrentQueue <FeatureCommand> commands; if (!_commandsByDevice.TryGetValue(deviceId, out commands)) { commands = new ConcurrentQueue <FeatureCommand>(); _commandsByDevice[deviceId] = commands; } commands.Enqueue(command); }
public static FeatureCommand GetCommand(string name = null, string ticket = null, string id = null) { string defaultId = "id1"; string defaultName = "Feature 1"; string defaultTicket = "ticket1"; DateTime date = DateTime.Now; string user = "******"; id = id ?? defaultId; name = name ?? defaultName; ticket = ticket ?? defaultTicket; FeatureCommand command = new FeatureCommand(id, date, name, user, ticket); return(command); }
public static FeatureCommandResult Validate(FeatureCommand command, IWriteRepository <Feature> write, IReadRepository <Feature> read) { if (write == null) { throw new Exception("WriteRespository can not be a null value."); } if (read == null) { throw new Exception("ReadRespository can not be a null value."); } if (command == null) { throw new ArgumentNullException("command"); } FeatureCommandResult result = new FeatureCommandResult(); result.Valid = true; if (string.IsNullOrWhiteSpace(command.Id)) { result.Valid = false; result.InvalidName = MessagesModel.Required; } if (string.IsNullOrWhiteSpace(command.Name)) { result.Valid = false; result.InvalidName = MessagesModel.Required; } if (command.Name != null && command.Name.Length > 100) { result.Valid = false; result.InvalidName = string.Format(MessagesModel.MaxLength, "100"); } if (command.Ticket != null && command.Ticket.Length > 100) { result.Valid = false; result.InvalidTicket = string.Format(MessagesModel.MaxLength, "100"); } return(result); }
public void Validate_Should_Not_Add_Feature_With_Duplicate_Name() { FeatureCommand command = FeatureCommandHandlerTestHelper.GetCommand(); IList <Feature> features = Substitute.For <IList <Feature> >(); features.Count.Returns(1); read.Where(x => x.Name == "Feature 1").ReturnsForAnyArgs(features); string expectedInvalid = string.Format("A feature already exists with the name {0}", command.Name); FeatureCommandResult result = FeatureCommandHandlerHelper.Validate(command, this.write, this.read); Assert.IsFalse(result.Valid); Assert.AreEqual(expectedInvalid, result.InvalidName); }
public void Validate_Should_Throw_Exception_When_Command_Is_Null() { FeatureCommand command = null; FeatureCommandHandlerHelper.Validate(command, this.write, this.read); }
public void Post(Feature feature) { FeatureCommand command = new FeatureCommand(feature.Id, feature.DateAdded, feature.Name, feature.UserId, feature.Ticket, feature.IsActive, feature.IsEnabled, feature.StrategyId); FeatureCommandResult result = this.commandDispatcher.Dispatch <FeatureCommand, FeatureCommandResult, Feature>(command); }