private List <PCConfiguration> CreateConfigurations(IList <PCComponent> componentsToInsert) { var configurations = new List <PCConfiguration>(); for (var i = 0; i < 5; i++) { var configuration = new PCConfiguration(); configuration.WithName(NamesGenerator.ConfigurationName(i)) .WithComponent(componentsToInsert.RandomElementExcept(configuration.Components.ToList())) .WithComponent(componentsToInsert.RandomElementExcept(configuration.Components.ToList())) .WithComponent(componentsToInsert.RandomElementExcept(configuration.Components.ToList())); configurations.Add(configuration); if (_random.NextDouble() > 0.5) { configuration.MoveToStatus(PCConfigurationStatus.Published); } } return(configurations); }
public void FindPublishedConfigurations_NotEmptyName_ShouldReturnPublishedConfigurationsWithSpecifiedName() { //Arrange var requestedName = NamesGenerator.ConfigurationName(); var configurationsList = new List <PCConfiguration> { new Mock <PCConfiguration>().Object.WithName(NamesGenerator.ConfigurationName(1)), new Mock <PCConfiguration>().Object.WithName(requestedName), new Mock <PCConfiguration>().Object.WithName(requestedName), new Mock <PCConfiguration>().Object.WithName(NamesGenerator.ConfigurationName(2)) }; configurationsList[1].MoveToStatus(PCConfigurationStatus.Published); configurationsList[3].MoveToStatus(PCConfigurationStatus.Published); MockWorkplace.Setup(x => x.Query <PCConfiguration>()).Returns(configurationsList.AsQueryable()); //Act var retrievedConfigurations = Repository.FindPublishedConfigurations(requestedName).ToList(); //Assert Assert.That(retrievedConfigurations.Count == 1); Assert.That(retrievedConfigurations.First().Status == PCConfigurationStatus.Published); Assert.That(retrievedConfigurations.First().Name == requestedName); }