public async Task Handle_ShouldReturnOkResult() { using (new IPOContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var dut = new GetMcPkgsUnderCommPkgInProjectQueryHandler(_mcPkgApiServiceMock.Object, _plantProvider); var result = await dut.Handle(_query, default); Assert.AreEqual(ResultType.Ok, result.ResultType); } }
public async Task Handle_ShouldReturnEmptyList_WhenSearchReturnsNull() { using (new IPOContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var dut = new GetMcPkgsUnderCommPkgInProjectQueryHandler(_mcPkgApiServiceMock.Object, _plantProvider); _mcPkgApiServiceMock .Setup(x => x.GetMcPkgsByCommPkgNoAndProjectNameAsync(TestPlant, _projectName, _commPkgNo)) .Returns(Task.FromResult <IList <ProCoSysMcPkg> >(null)); var result = await dut.Handle(_query, default); Assert.AreEqual(ResultType.Ok, result.ResultType); Assert.AreEqual(0, result.Data.Count); } }
public async Task Handle_ShouldReturnCorrectItems() { using (new IPOContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var dut = new GetMcPkgsUnderCommPkgInProjectQueryHandler(_mcPkgApiServiceMock.Object, _plantProvider); var result = await dut.Handle(_query, default); Assert.AreEqual(3, result.Data.Count); var item1 = result.Data.ElementAt(0); var item2 = result.Data.ElementAt(1); var item3 = result.Data.ElementAt(2); AssertMcPkgData(_mainApiMcPkgs.Single(c => c.McPkgNo == item1.McPkgNo), item1); AssertMcPkgData(_mainApiMcPkgs.Single(t => t.McPkgNo == item2.McPkgNo), item2); AssertMcPkgData(_mainApiMcPkgs.Single(t => t.McPkgNo == item3.McPkgNo), item3); } }