Example #1
0
        public void GetCPUsByManufacture_GetCPUsFromRepository_RightEntitysReturned()
        {
            //Arrange
            Guid       guid1   = Guid.NewGuid();
            Guid       guid2   = Guid.NewGuid();
            Guid       guid3   = Guid.NewGuid();
            List <CPU> cpuList = new List <CPU> {
                new CPU {
                    ProductGuid = guid1, ProcessorNumber = "ProcNum1"
                },
                new CPU {
                    ProductGuid = guid2, ProcessorNumber = "ProcNum2"
                },
                new CPU {
                    ProductGuid = guid3, ProcessorNumber = "ProcNum3"
                }
            };

            CPUs.Setup(x => x.Get(It.IsAny <Expression <Func <CPU, bool> > >()))
            .Returns(cpuList.AsQueryable());

            //Act
            var result = buildService.GetCPUsByManufacture("Manuf1");

            //Assert
            Assert.IsNotNull(result.Where(x => x.ProductGuid == guid1), "guid1 is missing");
            Assert.IsNotNull(result.Where(x => x.ProductGuid == guid2), "guid2 is missing");
            Assert.IsNotNull(result.Where(x => x.ProductGuid == guid3), "guid3 is missing");

            Assert.IsNotNull(result
                             .Where(x => x.ProcessorNumber == cpuList[0].ProcessorNumber),
                             cpuList[0].ProcessorNumber + " is missing");
            Assert.IsNotNull(result
                             .Where(x => x.ProcessorNumber == cpuList[1].ProcessorNumber),
                             cpuList[0].ProcessorNumber + " is missing");
            Assert.IsNotNull(result
                             .Where(x => x.ProcessorNumber == cpuList[2].ProcessorNumber),
                             cpuList[0].ProcessorNumber + " is missing");
        }