Example #1
0
        public string CreateTestAndReturnName(string testName)
        {
            if (AuthCheck.NewCheck().MustBeInRole("Dev").IsNotSatisfiedBy(_currentUserFactory.GetCurrentUser()))
            {
                throw new UserNotAuthorisedException();
            }

            Guid            newTestId = Guid.NewGuid();
            TestSaveCommand cmd       = new TestSaveCommand()
            {
                Id       = newTestId,
                TestName = testName
            };

            _commandProcessor.Execute(cmd);


            TestQuery qry = new TestQuery()
            {
                Id = newTestId
            };

            Test domainEntity = _queryProcessor.Execute(qry);

            if (domainEntity != null)
            {
                return(domainEntity.TestName);
            }
            else
            {
                throw new Exception("Couldn't get test from database.");
            }
        }