public void Service_GetPending_Should_Return_Items() { var id = Faker.Generate <Guid>(); var item = AutoFaker.Generate <Item>(); var item1Override = new ProductCodeOverride(); var item2Override = new ProductCodeOverride(); var items = new List <Item> { Faker.Generate <Item, ItemFaker>(builder => builder.WithArgs(id).WithOverride(item1Override)), AutoFaker.Generate <Item, ItemFaker>(builder => builder.WithArgs(id).WithOverride(item2Override)) }; item.Status = ItemStatus.Pending; items.Add(item); _repository.GetFiltered(Service.PendingFilter).Returns(items); _service.GetPending().Should().BeSameAs(items); items.ElementAt(0).ProductInt.Code.SerialNumber.Should().Be(item1Override.Code); items.ElementAt(0).ProductString.Code.SerialNumber.Should().Be(item1Override.Code); items.ElementAt(1).ProductInt.Code.SerialNumber.Should().Be(item2Override.Code); items.ElementAt(1).ProductString.Code.SerialNumber.Should().Be(item2Override.Code); items.ElementAt(2).ProductInt.Code.SerialNumber.Should().BeNull(); items.ElementAt(2).ProductString.Code.SerialNumber.Should().BeNull(); }
public void Service_GetPending_Should_Return_Items() { var id = _faker.Generate <Guid>(); var item = AutoFaker.Generate <Item>(); var item1Override = new ProductCodeOverride(); var item2Override = new ProductCodeOverride(); var items = new List <Item> { _faker.Generate <Item, ItemFaker>(builder => builder.WithArgs(id).WithOverride(item1Override)), AutoFaker.Generate <Item, ItemFaker>(builder => builder.WithArgs(id).WithOverride(item2Override)), AutoFaker.Generate <Item>(builder => builder.WithSkip <Item>(i => i.ProcessedBy)), AutoFaker.Generate <Item>(builder => builder.WithConventions(c => c.Email.Aliases("SupplierEmail"))) }; item.Status = ItemStatus.Pending; items.Add(item); _repository.GetFiltered(Service.PendingFilter).Returns(items); _service.GetPending().Should().BeSameAs(items); items.ElementAt(0).ProcessedBy.Email.Should().NotContain("@"); items.ElementAt(0).SupplierEmail.Should().NotContain("@"); items.ElementAt(0).ProductInt.Code.SerialNumber.Should().Be(item1Override.Code); items.ElementAt(0).ProductString.Code.SerialNumber.Should().Be(item1Override.Code); items.ElementAt(1).ProcessedBy.Email.Should().NotContain("@"); items.ElementAt(1).SupplierEmail.Should().NotContain("@"); items.ElementAt(1).ProductInt.Code.SerialNumber.Should().Be(item2Override.Code); items.ElementAt(1).ProductString.Code.SerialNumber.Should().Be(item2Override.Code); items.ElementAt(2).ProcessedBy.Should().BeNull(); items.ElementAt(2).SupplierEmail.Should().NotContain("@"); items.ElementAt(2).ProductInt.Code.SerialNumber.Should().BeNull(); items.ElementAt(2).ProductString.Code.SerialNumber.Should().BeNull(); items.ElementAt(3).ProcessedBy.Email.Should().Contain("@"); items.ElementAt(3).SupplierEmail.Should().Contain("@"); items.ElementAt(3).ProductInt.Code.SerialNumber.Should().BeNull(); items.ElementAt(3).ProductString.Code.SerialNumber.Should().BeNull(); items.ElementAt(4).ProcessedBy.Email.Should().NotContain("@"); items.ElementAt(4).SupplierEmail.Should().NotContain("@"); items.ElementAt(4).ProductInt.Code.SerialNumber.Should().BeNull(); items.ElementAt(4).ProductString.Code.SerialNumber.Should().BeNull(); }