Exemplo n.º 1
0
        public async void handle_Exception_test()
        {
            Project             returnn = new Project();
            OrganisationProject op      = new OrganisationProject();
            ProjectCategory     pc      = new ProjectCategory();
            ProjectResearcher   pr      = new ProjectResearcher();

            this._unitOfUnitMock.Setup(mock => mock.ProjectRepository.Update(It.IsAny <Project>())).Returns(returnn);
            this._unitOfUnitMock.Setup(mock => mock.RelationsRepository.DeleteProjectOrganisation(It.IsAny <int>()))
            .Returns(true);
            this._unitOfUnitMock.Setup(mock =>
                                       mock.RelationsRepository.CreateOrganisationProject(It.IsAny <OrganisationProject>())).Returns(op);
            this._unitOfUnitMock.Setup(mock => mock.RelationsRepository.DeleteCategoriesProject(It.IsAny <int>()))
            .Returns(true);
            this._unitOfUnitMock
            .Setup(mock => mock.RelationsRepository.CreateProjectCategory(It.IsAny <ProjectCategory>())).Returns(pc);
            this._unitOfUnitMock
            .Setup(mock => mock.RelationsRepository.DeleteProjectResearcherWithProjectId(It.IsAny <int>()))
            .Returns(true);
            this._unitOfUnitMock
            .Setup(mock => mock.RelationsRepository.CreateProjectResearcher(It.IsAny <ProjectResearcher>()))
            .Throws(new Exception());

            UpdateProjectCommand command = new UpdateProjectCommand(new CreateProjectModel()
            {
                ProjectName = "test",
                Categories  = new List <Category>()
                {
                    new Category()
                    {
                        CategoryId = 1, CategoryName = "test", Created = DateTime.Now, Id = 1
                    }
                },
                ResearcherCategories = new List <ResearcherCategory>()
                {
                    new ResearcherCategory()
                    {
                        Researcher = new Researcher()
                        {
                            Id = 1
                        }, Category = new Category()
                        {
                            Id = 1
                        }
                    }
                },
                Organisations = new List <Organisation>()
                {
                    new Organisation()
                    {
                        Id = 1,
                    }
                }
            });
            UpdateProjectHandler handler = new UpdateProjectHandler(this._unitOfUnitMock.Object);

            var result = await handler.Handle(command, new CancellationTokenSource().Token);

            Assert.Null(result);
        }
Exemplo n.º 2
0
        public async void handle_ProjectResutlNull_test()
        {
            Project returnn = null;

            this._unitOfUnitMock.Setup(mock => mock.ProjectRepository.Update(It.IsAny <Project>())).Returns(returnn);

            UpdateProjectCommand command = new UpdateProjectCommand(new CreateProjectModel()
            {
                ProjectName = "test"
            });
            UpdateProjectHandler handler = new UpdateProjectHandler(this._unitOfUnitMock.Object);

            var result = await handler.Handle(command, new CancellationTokenSource().Token);

            Assert.Null(result);
        }