Beispiel #1
0
        public async void ExecuteWithNoExistingFindingsStatesTest()
        {
            //Arrange
            var findingsS = new FindingsState("code1", "name1", "colour1", true, 1);
            var mockFindingsStatesCriteriaRepository = new Mock <IFindingStateRepository>();

            mockFindingsStatesCriteriaRepository.Setup(e => e.Get(It.IsNotNull <string>(), It.IsNotNull <string>(), It.IsNotNull <string>())).Returns(findingsS);
            mockFindingsStatesCriteriaRepository.Setup(e => e.Update(It.IsNotNull <FindingsState>())).Returns(findingsS);

            var useCase = new UpdateFindingsStatesUseCase(mockFindingsStatesCriteriaRepository.Object);

            //Act

            //Assert
            Assert.Throws <EntityNotFoundException>(() => useCase.Execute(1, "code1", "name1", "colour1", true));
        }
Beispiel #2
0
        public FindingsState Update(FindingsState updateparam)
        {
            using (var scope = _serviceProvider.CreateScope())
            {
                var _ctx = scope.ServiceProvider.GetService(typeof(SQLHoshinCoreContext)) as SQLHoshinCoreContext;

                var findingsState = _ctx.FindingsStates.Where(x => x.FindingStateID == updateparam.Id).FirstOrDefault();
                findingsState.Name   = updateparam.Name;
                findingsState.Colour = updateparam.Colour;
                findingsState.Code   = updateparam.Code;
                findingsState.Active = updateparam.Active;
                _ctx.Update(findingsState);
                _ctx.SaveChanges();

                return(updateparam);
            }
        }
Beispiel #3
0
        public async void ExecuteWithExistingFindingsStatesTest()
        {
            //Arrange
            var findingsS = new FindingsState("code1", "name1", "colour1", true, 1);
            var mockFindingsStatesCriteriaRepository = new Mock <IFindingStateRepository>();

            mockFindingsStatesCriteriaRepository.Setup(e => e.Get(It.IsNotNull <int>())).Returns(findingsS);
            mockFindingsStatesCriteriaRepository.Setup(e => e.Update(It.IsNotNull <FindingsState>())).Returns(findingsS);

            var useCase = new UpdateFindingsStatesUseCase(mockFindingsStatesCriteriaRepository.Object);
            //Act

            var res = useCase.Execute(1, "code1", "name1", "colour1", true);

            //Assert
            Assert.IsType <FindingsStatesOutput>(res);
        }
Beispiel #4
0
        public FindingsState Add(FindingsState newparam)
        {
            using (var scope = _serviceProvider.CreateScope())
            {
                var _ctx = scope.ServiceProvider.GetService(typeof(SQLHoshinCoreContext)) as SQLHoshinCoreContext;

                var findingsState = new FindingsStates();
                findingsState.Code   = newparam.Code;
                findingsState.Name   = newparam.Name;
                findingsState.Colour = newparam.Colour;
                findingsState.Active = newparam.Active;

                _ctx.FindingsStates.Add(findingsState);
                _ctx.SaveChanges();

                newparam.Id = findingsState.FindingStateID;

                return(newparam);
            }
        }