Пример #1
0
        public async Task Handle_ShouldReturnOkResult()
        {
            using (new IPOContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                var dut    = new GetPersonsWithPrivilegesQueryHandler(_personApiServiceMock.Object, _plantProvider);
                var result = await dut.Handle(_query, default);

                Assert.AreEqual(ResultType.Ok, result.ResultType);
            }
        }
Пример #2
0
        public async Task HandleGetConstructionPersons_ShouldReturnEmptyList_WhenSearchReturnsNull()
        {
            _query = new GetPersonsWithPrivilegesQuery(_searchString, _objectName, _privileges);

            using (new IPOContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                var dut = new GetPersonsWithPrivilegesQueryHandler(_personApiServiceMock.Object, _plantProvider);
                _personApiServiceMock
                .Setup(x => x.GetPersonsWithPrivilegesAsync(TestPlant, _searchString, _objectName, _privileges))
                .Returns(Task.FromResult <IList <ProCoSysPerson> >(null));

                var result = await dut.Handle(_query, default);

                Assert.AreEqual(ResultType.Ok, result.ResultType);
                Assert.AreEqual(0, result.Data.Count);
            }
        }
Пример #3
0
        public async Task HandleGetConstructionPersons_ShouldReturnCorrectItems()
        {
            using (new IPOContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                _personApiServiceMock
                .Setup(x => x.GetPersonsWithPrivilegesAsync(TestPlant, _searchString, _objectName, _privileges))
                .Returns(Task.FromResult(_mainApiConstructionPersons));

                _query = new GetPersonsWithPrivilegesQuery(_searchString, _objectName, _privileges);

                var dut    = new GetPersonsWithPrivilegesQueryHandler(_personApiServiceMock.Object, _plantProvider);
                var result = await dut.Handle(_query, default);

                Assert.AreEqual(3, result.Data.Count);
                var person1 = result.Data.ElementAt(0);
                var person2 = result.Data.ElementAt(1);
                var person3 = result.Data.ElementAt(2);
                AssertPersonData(_mainApiConstructionPersons.Single(c => c.AzureOid == person1.AzureOid), person1);
                AssertPersonData(_mainApiConstructionPersons.Single(t => t.AzureOid == person2.AzureOid), person2);
                AssertPersonData(_mainApiConstructionPersons.Single(t => t.AzureOid == person3.AzureOid), person3);
            }
        }