public void IsSatisfied_PlugSlotsCountIsLargerThanContainedSlotsOfTheSameType_ShouldFail() { //Arrange AddAllRequiredComponentsAndValidName(); var plugSlot = DomainObjectsCreator.CreateInterface(1); ComponentAt(0).WithPlugSlot(plugSlot); ComponentAt(2).WithPlugSlot(plugSlot); ComponentAt(3).WithPlugSlot(plugSlot); ComponentAt(4).WithContainedComponent( CreateValidComponent(ComponentType.CentralProcessingUnit) .WithContainedSlot(plugSlot) .WithContainedSlot(plugSlot)); //Act var result = _detailedSpecification.IsSatisfiedBy(Configuration); //Assert Assert.That(!result.IsSatisfied); AssertNotFoundInterfaceInfosEqual(result.FailureDetails.NotFoundInterfaces, new List <InterfaceDeficitInfo> { new InterfaceDeficitInfo(plugSlot, 1, new[] { ComponentAt(0), ComponentAt(2), ComponentAt(3) }) }); }
private IList <ComponentInterface> CreateInterfaces() { return(new[] { DomainObjectsCreator.CreateInterface(1), DomainObjectsCreator.CreateInterface(2), DomainObjectsCreator.CreateInterface(3) }); }
public void WithComponent_ComponentWithSameIdentity_ShouldThrowDuplicateElementException() { //Arrange var component = DomainObjectsCreator.CreateComponent(0, ComponentType.Motherboard); DefaultConfiguration.WithComponent(component); //Assert Assert.That(() => DefaultConfiguration.WithComponent(component), Throws.InstanceOf <DuplicateElementException>()); }
private List <ComponentInterface> FillRepositoryWithFakes(int fakesCount) { var intsList = new List <ComponentInterface>(); for (var i = 0; i < fakesCount; i++) { intsList.Add(DomainObjectsCreator.CreateInterface(i)); } RepositoryMock.Setup(x => x.Query(It.IsAny <PersistenceAwareSpecification <ComponentInterface> >())) .Returns(intsList.AsAsyncQueryable()); return(intsList); }
public void CalculatePrice_SomeComponentsAdded_ShouldReturnSumPriceOfAllComponents() { //Arrange DefaultConfiguration .WithComponent( DomainObjectsCreator.CreateComponent(0, ComponentType.Motherboard).WithAveragePrice(100m)) .WithComponent( DomainObjectsCreator.CreateComponent(1, ComponentType.PowerSupply).WithAveragePrice(200m)) .WithComponent( DomainObjectsCreator.CreateComponent(2, ComponentType.SolidStateDrice).WithAveragePrice(350.5m)); //Assert Assert.That(DefaultConfiguration.CalculatePrice(), Is.EqualTo(650.5m)); }
public void GetComponentInterface_ComponentExists_ShouldReturnVOOfThatComponent() { //Arrange var dbComponent = DomainObjectsCreator.CreateInterface(1).WithId(Guid.NewGuid()); RepositoryMock.Setup(x => x.Query(It.IsAny <PersistenceAwareSpecification <ComponentInterface> >())) .Returns(new List <ComponentInterface> { dbComponent }.AsAsyncQueryable()); //Act var componentVO = Service.GetComponentInterface(dbComponent.Id).Result; //Assert Assert.That(componentVO.Id == dbComponent.Id); }
public void WithComponent_NewComponent_ShouldBeAddedToCollection() { //Arrange var firstComponent = DomainObjectsCreator.CreateComponent(0, ComponentType.PowerSupply); var secondComponent = DomainObjectsCreator.CreateComponent(1, ComponentType.Motherboard); //Act DefaultConfiguration .WithComponent(firstComponent) .WithComponent(secondComponent); //Assert Assert.That(DefaultConfiguration.Components.Count, Is.EqualTo(2)); Assert.That(DefaultConfiguration.Components.Contains(firstComponent)); Assert.That(DefaultConfiguration.Components.Contains(secondComponent)); }
public void Interpret_NotFoundInterfacesNotEmpty_ShouldReturnCorrespondingFailuresForEachProblemInterfaces() { //Arrange _detailsMock.SetupGet(x => x.NotFoundInterfaces) .Returns(new List <InterfaceDeficitInfo> { new InterfaceDeficitInfo(DomainObjectsCreator.CreateInterface(1), 1, new List <PCComponent> { DomainObjectsCreator.CreateComponent(1, ComponentType.HardDiskDrive) }), new InterfaceDeficitInfo(DomainObjectsCreator.CreateInterface(2), 2, new List <PCComponent> { DomainObjectsCreator.CreateComponent(1, ComponentType.HardDiskDrive) }) }); AssertInterpretedFailuresCount(2); }
public void IsSatisfied_RootComponentCanBePluggedOnlyToItself_ShouldFail() { //Arrange AddAllRequiredComponentsAndValidName(); var plugSlot = DomainObjectsCreator.CreateInterface(1); ComponentAt(0).WithPlugSlot(plugSlot) .WithContainedComponent( CreateValidComponent(ComponentType.SolidStateDrice) .WithContainedSlot(plugSlot)); //Act var result = _detailedSpecification.IsSatisfiedBy(Configuration); //Assert Assert.That(!result.IsSatisfied); Assert.That(result.FailureDetails.ComponentsCycleFailure); }
public void Query_ValidComponentType_ShouldQueryComponentsOfSpecifiedTypes() { //Arrange const ComponentType requestType = ComponentType.Motherboard; var components = new List <PCComponent> { DomainObjectsCreator.CreateComponent(0, requestType), DomainObjectsCreator.CreateComponent(0, ComponentType.HardDiskDrive), DomainObjectsCreator.CreateComponent(0, requestType), DomainObjectsCreator.CreateComponent(0, ComponentType.PowerSupply) }; MockWorkplace.Setup(x => x.Query <PCComponent>()) .Returns(components.AsQueryable()); //Act var queriesComponents = Repository.Query(requestType).ToList(); //Assert Assert.That(queriesComponents.Count == 2); Assert.That(queriesComponents.All(x => x.Type == requestType)); }
protected static PCComponent CreateComponent(int componentNameValue) { return(DomainObjectsCreator.CreateComponent(componentNameValue, ComponentType.SoundCard)); }
private static PCComponent CreateComponent() { return(DomainObjectsCreator.CreateComponent(1, ComponentType.HardDiskDrive)); }