protected override void SetupNewDatabase(DbContextOptions <IPOContext> dbContextOptions) { using (new IPOContext(dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { _commPkgApiServiceMock = new Mock <ICommPkgApiService>(); _mainApiCommPkgs = new List <ProCoSysCommPkg> { new ProCoSysCommPkg { Id = 1, CommPkgNo = "CommPkgNo1", Description = "Desc1", CommStatus = "PB" }, new ProCoSysCommPkg { Id = 2, CommPkgNo = "CommPkgNo2", Description = "Desc2", CommStatus = "OK" }, new ProCoSysCommPkg { Id = 3, CommPkgNo = "CommPkgNo3", Description = "Desc3", CommStatus = "PA" } }; var result = new ProCoSysCommPkgSearchResult { MaxAvailable = 3, Items = _mainApiCommPkgs }; _commPkgApiServiceMock .Setup(x => x.SearchCommPkgsByCommPkgNoAsync(TestPlant, _projectName, _commPkgStartsWith, _defaultPageSize, _defaultCurrentPage)) .Returns(Task.FromResult(result)); _query = new GetCommPkgsInProjectQuery(_projectName, _commPkgStartsWith, _defaultPageSize, _defaultCurrentPage); } }
public void Constructor_SetsProperties() { var dut = new GetCommPkgsInProjectQuery("ProjectName", "CommPkgNo", 10, 0); Assert.AreEqual("ProjectName", dut.ProjectName); Assert.AreEqual("CommPkgNo", dut.StartsWithCommPkgNo); Assert.AreEqual(10, dut.ItemsPerPage); Assert.AreEqual(0, dut.CurrentPage); }
public async Task ValidateAsync_OnGetCommPkgsInProjectQuery_ShouldReturnFalse_WhenNoAccessToProject() { // Arrange var query = new GetCommPkgsInProjectQuery(_projectWithoutAccess, null, 10, 0); // act var result = await _dut.ValidateAsync(query); // Assert Assert.IsFalse(result); }