public async Task Get_Return_Success() { // Arrange var unitUnderTest = CreateGarmentSubconCuttingOutController(); var id = Guid.NewGuid(); _mockSubconCuttingOutRepository .Setup(s => s.Read(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(new List <GarmentCuttingOutReadModel>().AsQueryable()); _mockSubconCuttingOutRepository .Setup(s => s.Find(It.IsAny <IQueryable <GarmentCuttingOutReadModel> >())) .Returns(new List <GarmentSubconCuttingOut>() { new GarmentSubconCuttingOut(id, "productCode", "cutOutType", new UnitDepartmentId(1), "unitFromCode", "unitFromName", DateTimeOffset.Now, "RONo", "article", new GarmentComodityId(1), "comodityCode", "comodityName", 1, 1, "remark") }); GarmentSubconCuttingOutItem garmentCuttingOutItem = new GarmentSubconCuttingOutItem(id, id, id, id, new ProductId(1), "productCode", "productName", "designColor", 1); _mockSubconCuttingOutItemRepository .Setup(s => s.Query) .Returns(new List <GarmentCuttingOutItemReadModel>() { garmentCuttingOutItem.GetReadModel() }.AsQueryable()); _mockSubconCuttingOutItemRepository .Setup(s => s.Find(It.IsAny <IQueryable <GarmentCuttingOutItemReadModel> >())) .Returns(new List <GarmentSubconCuttingOutItem>() { new GarmentSubconCuttingOutItem(id, id, id, id, new ProductId(1), "productCode", "productName", "designColor", 1) }); GarmentSubconCuttingOutDetail garmentCuttingOutDetail = new GarmentSubconCuttingOutDetail(id, id, new SizeId(1), "sizeName", "color", 1, 1, new UomId(1), "cuttingOutUomUnit", 1, 1, "remark"); _mockSubconCuttingOutDetailRepository .Setup(s => s.Query) .Returns(new List <GarmentCuttingOutDetailReadModel>() { garmentCuttingOutDetail.GetReadModel() }.AsQueryable()); _mockSubconCuttingOutDetailRepository .Setup(s => s.Find(It.IsAny <IQueryable <GarmentCuttingOutDetailReadModel> >())) .Returns(new List <GarmentSubconCuttingOutDetail>() { new GarmentSubconCuttingOutDetail(id, id, new SizeId(1), "sizeName", "color", 1, 1, new UomId(1), "cuttingOutUomUnit", 1, 1, "remark") }); // Act var orderData = new { article = "desc", }; string order = JsonConvert.SerializeObject(orderData); var result = await unitUnderTest.Get(1, 25, order, new List <string>(), "productCode", "{}"); // Assert Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(result)); }
public async Task Get_StateUnderTest_ExpectedBehavior() { // Arrange var unitUnderTest = CreateGarmentSubconCuttingOutController(); _mockSubconCuttingOutRepository .Setup(s => s.Read(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(new List <GarmentCuttingOutReadModel>().AsQueryable()); Guid cuttingOutGuid = Guid.NewGuid(); _mockSubconCuttingOutRepository .Setup(s => s.Find(It.IsAny <IQueryable <GarmentCuttingOutReadModel> >())) .Returns(new List <GarmentSubconCuttingOut>() { new GarmentSubconCuttingOut(cuttingOutGuid, null, null, new UnitDepartmentId(1), null, null, DateTimeOffset.Now, "RONo", null, new GarmentComodityId(1), null, null, 1, 1, null) }); Guid cuttingOutItemGuid = Guid.NewGuid(); GarmentSubconCuttingOutItem garmentCuttingOutItem = new GarmentSubconCuttingOutItem(cuttingOutItemGuid, cuttingOutGuid, Guid.NewGuid(), Guid.NewGuid(), new ProductId(1), null, null, null, 1); _mockSubconCuttingOutItemRepository .Setup(s => s.Query) .Returns(new List <GarmentCuttingOutItemReadModel>() { garmentCuttingOutItem.GetReadModel() }.AsQueryable()); _mockSubconCuttingOutItemRepository .Setup(s => s.Find(It.IsAny <IQueryable <GarmentCuttingOutItemReadModel> >())) .Returns(new List <GarmentSubconCuttingOutItem>() { new GarmentSubconCuttingOutItem(cuttingOutItemGuid, cuttingOutGuid, Guid.NewGuid(), Guid.NewGuid(), new ProductId(1), null, null, null, 1) }); GarmentSubconCuttingOutDetail garmentCuttingOutDetail = new GarmentSubconCuttingOutDetail(Guid.NewGuid(), cuttingOutItemGuid, new SizeId(1), null, null, 1, 1, new UomId(1), null, 1, 1, null); _mockSubconCuttingOutDetailRepository .Setup(s => s.Query) .Returns(new List <GarmentCuttingOutDetailReadModel>() { garmentCuttingOutDetail.GetReadModel() }.AsQueryable()); _mockSubconCuttingOutDetailRepository .Setup(s => s.Find(It.IsAny <IQueryable <GarmentCuttingOutDetailReadModel> >())) .Returns(new List <GarmentSubconCuttingOutDetail>() { new GarmentSubconCuttingOutDetail(Guid.NewGuid(), cuttingOutItemGuid, new SizeId(1), null, null, 1, 1, new UomId(1), null, 1, 1, null) }); // Act var result = await unitUnderTest.Get(); // Assert Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(result)); }