コード例 #1
0
            public void ContextSetup()
            {
                _serverId1 = Guid.NewGuid();
                _serverId2 = Guid.NewGuid();
                var existingMasterModel = new MasterModel();

                existingMasterModel.CreateProject(x => x.Name = "Existing Project");
                var cruiseProjects = new[]
                {
                    new EditProjectCruiseProject {
                        Server = _serverId1, Project = "Project 1.1"
                    },
                    new EditProjectCruiseProject {
                        Server = _serverId1, Project = "Project 1.2"
                    },
                    new EditProjectCruiseProject {
                        Server = _serverId2, Project = "Project 2.1"
                    },
                    new EditProjectCruiseProject {
                        Server = _serverId2, Project = "Project 2.2"
                    }
                };

                var repository = new StubMasterModelRepository();

                repository.UseCurrentModel(existingMasterModel);

                var creator = new ProjectManager(repository);

                _result = creator.Create(new EditProject {
                    Name = "My New Project", CruiseProjects = cruiseProjects
                });

                _savedModel = repository.LastSaved;
            }
コード例 #2
0
        public void ShouldReturnsErrorWhenPasswordIsEmpty(string password)
        {
            CreationResult <Password, Error> result = Password.CreateAndValidate(value: password);

            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(result.Error, Error.Required);
        }
コード例 #3
0
        public void CreatedNew(CreationResult cr)
        {
            //Console.WriteLine("@@@ created new " + cr);

            if (this.state != StatKind.Selected)
            {
                throw new Common.RandoopBareExceptions.InternalError("Bug in Randoop.StatsManager.");
            }

            if (cr == CreationResult.NoInputs)
            {
                writer.WriteLine(cr.ToString());
                writer.Flush();

                // Go back to the initial state.
                state = StatKind.Start;
            }
            else if (cr == CreationResult.Redundant)
            {
                writer.WriteLine(cr.ToString());
                writer.Flush();

                // Go back to the initial state.
                state = StatKind.Start;
            }
            else
            {
                writer.Write(cr.ToString());
                writer.Write("#");
                writer.Flush();

                state = StatKind.CreatedNewPlan;
            }
        }
コード例 #4
0
        public void ShouldReturnsErrorWhenEmailIsEmpty(string userEmail)
        {
            CreationResult <Email, Error> result = Email.CreateAndValidate(value: userEmail);

            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(result.Error, Error.Required);
        }
コード例 #5
0
        public void WithSource_FailedResultWith2Errors_ShouldUpdateOnlyNeededSource()
        {
            var errorSource1 = SourceBuilder.BuildErrorSource <FakeCreateCommand>(c => c.AggregateRootId);
            var errorSource2 = SourceBuilder.BuildErrorSource <FakeCreateCommand>(c => c.SomeArray[0].SomeInternalArray[0].SomeInt);

            var executionErrors = new[]
            {
                new ExecutionError(new ErrorCodeInfo(nameof(Core), FixtureUtils.String(), FixtureUtils.String()), errorSource1),
                new ExecutionError(new ErrorCodeInfo(nameof(Core), FixtureUtils.String(), FixtureUtils.String()), errorSource2)
            };

            var result = new CreationResult <DummyEntry>(executionErrors)
                         .WithSource <DummyEntry, FakeCreateCommand>(c => c.SomeArray[3]);

            result.Entry.Should().BeNull();

            var internalErrors = result.Errors.ToArray();

            internalErrors[0].CodeInfo.Should().Be(executionErrors[0].CodeInfo);
            internalErrors[0].Code.Should().Be(executionErrors[0].Code);
            internalErrors[0].Message.Should().Be(executionErrors[0].Message);
            internalErrors[0].Source.Should().Be(errorSource1);

            internalErrors[1].CodeInfo.Should().Be(executionErrors[1].CodeInfo);
            internalErrors[1].Code.Should().Be(executionErrors[1].Code);
            internalErrors[1].Message.Should().Be(executionErrors[1].Message);
            internalErrors[1].Source.Should().Be("FakeCreateCommand.SomeArray.3.SomeInternalArray.0.SomeInt");
        }
コード例 #6
0
ファイル: ProjectManager.cs プロジェクト: mhinze/ZBuildLights
        public CreationResult <Project> Create(EditProject editModel)
        {
            if (string.IsNullOrEmpty(editModel.Name))
            {
                return(CreationResult.Fail <Project>("Project name is required."));
            }
            var currentModel = _masterModelRepository.GetCurrent();

            if (IsProjectNameAlreadyUsed(editModel.Name, currentModel))
            {
                return(CreationResult.Fail <Project>(NameCollisionMessage(editModel.Name)));
            }

            var project = currentModel.CreateProject(x =>
            {
                x.Name = editModel.Name;
                x.CruiseProjectAssociations =
                    editModel.SafeProjects.Select(
                        cp => new CruiseProjectAssociation {
                    ServerId = cp.Server, Name = cp.Project
                })
                    .ToArray();
            });

            _masterModelRepository.Save(currentModel);

            return(CreationResult.Success(project));
        }
コード例 #7
0
        private CreationResult buildProcess(IModel model, IBuildConfiguration buildConfiguration,
                                            params Func <IModel, IBuildConfiguration, ValidationResult>[] steps)
        {
            var result = new CreationResult(model);
            IProgressUpdater progress = null;

            try
            {
                if (buildConfiguration.ShowProgress)
                {
                    progress = _progressManager.Create();
                    progress.Initialize(steps.Length, Messages.CreatingModel);
                }

                foreach (var step in steps)
                {
                    //call each build process with the model and the buildconfiguration
                    result.Add(step(model, buildConfiguration));

                    progress?.IncrementProgress();

                    //if the result has become invalid, stop the build process
                    if (result.IsInvalid)
                    {
                        break;
                    }
                }
            }
            finally
            {
                progress?.Dispose();
            }

            return(result);
        }
コード例 #8
0
        public void ForCommand_SuccessResult_ShouldReturnTheSameResult()
        {
            var creationResult = CreationResult.Succeeded(new DummyEntry());

            creationResult.ForCommand <DummyEntry, FakeCreateCommand>(c => c.Data)
            .Should().BeEquivalentTo(creationResult);
        }
コード例 #9
0
        public void Constructor_Always_CreatesFailedWithoutEntry()
        {
            var result = new CreationResult <DummyEntry>();

            result.Entry.Should().BeNull();
            result.Errors.Should().BeEmpty();
        }
コード例 #10
0
        public void Failed_WithErrorCode_ReturnsResultWithSameErrorCode()
        {
            var errorCode     = new ErrorCodeInfo(nameof(Core), FixtureUtils.String(), FixtureUtils.String());
            var expectedError = new ExecutionError(errorCode);

            CreationResult.Failed <DummyEntry>(errorCode)
            .Should().BeEquivalentTo(new CreationResult <DummyEntry>(expectedError));
        }
コード例 #11
0
        public static async Task Run([ActivityTrigger] CreationResult input, ILogger log, ExecutionContext context)
        {
            var client = GraphServiceClientFactory.GetInstance(context?.FunctionAppDirectory).Client.Value;

            if (!await DoesTeamExist(input, client))
            {
                await EnableTeams(input, client);
            }
        }
コード例 #12
0
        public void ShouldCreatesValidEmail()
        {
            var userEmail = "*****@*****.**";

            CreationResult <Email, Error> result = Email.CreateAndValidate(value: userEmail);

            Assert.IsTrue(result.IsValid);
            Assert.AreEqual(result.Result.Value, userEmail);
        }
コード例 #13
0
        public void ShouldReturnsErrorWhenEmailFormatIsInvalid()
        {
            var userEmail = "invalid.com";

            CreationResult <Email, Error> result = Email.CreateAndValidate(value: userEmail);

            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(result.Error, Error.InvalidFormat);
        }
コード例 #14
0
        public void ShouldCreateInvalidResult()
        {
            var result = CreationResult <ResultForTest, ErrorForTest> .CreateInvalidResult(
                error : ErrorForTest.AnyError
                );

            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(result.Error, ErrorForTest.AnyError);
        }
コード例 #15
0
        public void ShouldReturnsErrorWhenPasswordDoesNotContainAtLeastOfOneSymbol()
        {
            var password = "******";

            CreationResult <Password, Error> result = Password.CreateAndValidate(value: password);

            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(result.Error, Error.InvalidFormat);
        }
コード例 #16
0
 private void StubFakeObjectCreatorWithValue <T>(T value)
 {
     A.CallTo(() => this.fakeObjectCreator.CreateFakeWithoutLoopDetection(
                  typeof(T),
                  A <IProxyOptions> ._,
                  A <IDummyValueResolver> ._,
                  A <LoopDetectingResolutionContext> ._))
     .Returns(CreationResult.SuccessfullyCreated(value));
 }
コード例 #17
0
        public void ShouldReturnsErrorWhenPasswordIsNotAlphanumeric()
        {
            var password = "******";

            CreationResult <Password, Error> result = Password.CreateAndValidate(value: password);

            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(result.Error, Error.InvalidFormat);
        }
コード例 #18
0
        public void ShouldReturnsErrorWhenPasswordDoesNotContainAtLeastOfOneUpperCaseLetter()
        {
            var password = "******";

            CreationResult <Password, Error> result = Password.CreateAndValidate(value: password);

            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(result.Error, Error.InvalidFormat);
        }
コード例 #19
0
        public void ShouldReturnsErrorWhenPasswordLenghtIsLowerThan8()
        {
            var password = "******";

            CreationResult <Password, Error> result = Password.CreateAndValidate(value: password);

            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(result.Error, Error.InvalidFormat);
        }
コード例 #20
0
        public void ShouldCreatesValidPasswords()
        {
            var password = "******";

            CreationResult <Password, Error> result = Password.CreateAndValidate(value: password);

            Assert.IsTrue(result.IsValid);
            Assert.AreEqual(result.Result.Value, password);
        }
コード例 #21
0
        public void WithSource_SuccessResult_ShouldReturnTheSameResult()
        {
            var creationResult = CreationResult.Succeeded(new DummyEntry());

            var result = creationResult
                         .ForCommand <DummyEntry, FakeCreateCommand>(c => c.SomeArray[0].SomeInternalArray[0].SomeInt)
                         .WithSource <DummyEntry, FakeCreateCommand>(c => c.SomeArray[3].SomeInternalArray[1]);

            result.Should().BeEquivalentTo(creationResult);
        }
コード例 #22
0
        public static CreationResult <Post> Create(PostCreateCommand command)
        {
            var newGuid          = Guid.NewGuid();
            var post             = new Post(newGuid, command);
            var createEvent      = new PostCreateEvent(post, newGuid);
            var domainEventBases = new List <DomainEventBase>();

            domainEventBases.Add(createEvent);
            return(CreationResult <Post> .OkResult(domainEventBases, post));
        }
コード例 #23
0
        private static async Task <string> CreateChannel(CreationResult input, GraphServiceClient client)
        {
            var channel = await client.Teams[input.GroupId].Channels.Request().AddAsync(new Channel
            {
                DisplayName = input.FullProjectTitle,
                Description = input.ProjectDescription,
            });

            return(channel.Id);
        }
コード例 #24
0
        public static CreationResult <User> Create(UserCreateCommand command)
        {
            // TODO: Implement this method;
            var newGuid = Guid.NewGuid();
            var entity  = new User(newGuid, command);

            return(CreationResult <User> .OkResult(new List <DomainEventBase> {
                new UserCreateEvent(entity, newGuid)
            }, entity));
        }
        public static async Task Run([ActivityTrigger] CreationResult input, ILogger log, ExecutionContext context)
        {
            log.LogInformation("creating library tabs for client");
            var client     = GraphServiceClientFactory.GetInstance(context?.FunctionAppDirectory).Client.Value;
            var tabService = new TeamsTabService(client, AppDefId);

            await AddConfiguredLibTabsToChannel(input.GroupId, input.ProjectChannelId, input.ProjectSiteUrl, client, tabService, input.ProjectChannelLibTabsLibNames, webExtraction);

            log.LogInformation("created library tabs for client");
        }
コード例 #26
0
        public CreationResult <Generalization, GeneralizationViewHelper> NewGeneralization(Class general, Class specific)
        {
            CreationResult <Generalization, GeneralizationViewHelper> result = new CreationResult <Generalization, GeneralizationViewHelper>();
            NewModelGeneralizationToDiagramCommand generalizationCommand     = (NewModelGeneralizationToDiagramCommand)NewModelGeneralizationToDiagramCommandFactory.Factory().Create(this);

            generalizationCommand.Set(ModelController, ModelController.Model, general, specific);
            generalizationCommand.Execute();
            result.ModelElement = generalizationCommand.CreatedGeneralization;
            result.ViewHelper   = generalizationCommand.ViewHelper;
            return(result);
        }
コード例 #27
0
        public CreationResult <User, SignUpError> Execute(UserSignUpRequest request)
        {
            if (userRepository.Exist(email: request.Email))
            {
                return(CreationResult <User, SignUpError> .CreateInvalidResult(SignUpError.UserAlreadyExist));
            }
            var user = HashPasswordAndCreateUser(request);

            userRepository.Create(user);
            return(CreationResult <User, SignUpError> .CreateValidResult(user));
        }
コード例 #28
0
        public void ShouldCreateValidResult()
        {
            var resultForTest = new ResultForTest(value: "test");

            var result = CreationResult <ResultForTest, ErrorForTest> .CreateValidResult(
                result : resultForTest
                );

            Assert.IsTrue(result.IsValid);
            Assert.AreEqual(result.Result.Value, resultForTest.Value);
        }
コード例 #29
0
        public void Constructor_WithErrors_CreatesRsultWithSameErrors()
        {
            var executionErrors = new[]
            {
                new ExecutionError(new ErrorCodeInfo(nameof(Core), FixtureUtils.String(), FixtureUtils.String())),
                new ExecutionError(new ErrorCodeInfo(nameof(Core), FixtureUtils.String(), FixtureUtils.String()))
            };

            var result = new CreationResult <DummyEntry>(executionErrors);

            var(errors, entry) = result;
            entry.Should().BeNull();
            errors.Should().BeEquivalentTo <ExecutionError>(executionErrors);
        }
コード例 #30
0
        private CreationResult CreateCdb()
        {
            CreationResult result = new CreationResult();

            result._cdbSettings  = null;
            result._cdbDirectory = "";
            result._cdbName      = "";

            Logging.Logging.LogInfo("Starting to create CDB");

            SolutionParser.CompilationDatabaseSettings cdbSettings = null;

            try
            {
                System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
                watch.Start();
                CreateCompilationDatabase();
                watch.Stop();

                Logging.Logging.LogInfo("Finished creating CDB, elapsed time: " + watch.ElapsedMilliseconds.ToString() + " ms");

                cdbSettings                                   = new CompilationDatabaseSettings();
                cdbSettings.Name                              = _fileName;
                cdbSettings.Directory                         = _targetDir;
                cdbSettings.SourceProject                     = _solutionDir;
                cdbSettings.LastUpdated                       = DateTime.Now;
                cdbSettings.ConfigurationName                 = _configurationName;
                cdbSettings.PlatformName                      = _platformName;
                cdbSettings.AdditionalClangOptions            = _additionalClangOptions;
                cdbSettings.NonSystemIncludesUseAngleBrackets = _nonSystemIncludesUseAngleBrackets;

                cdbSettings.IncludedProjects = new List <string>();
                foreach (EnvDTE.Project p in _projects)
                {
                    cdbSettings.IncludedProjects.Add(p.Name);
                }
            }
            catch (Exception e)
            {
                Logging.Logging.LogError("Failed to create CDB: " + e.Message);
            }

            result._cdbSettings  = cdbSettings;
            result._cdbDirectory = _targetDir;
            result._cdbName      = _fileName;

            Logging.Logging.LogInfo("Done creating CDB");

            return(result);
        }