Пример #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;
            }
        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);
        }
        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
        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);
        }
        public void ForCommand_SuccessResult_ShouldReturnTheSameResult()
        {
            var creationResult = CreationResult.Succeeded(new DummyEntry());

            creationResult.ForCommand <DummyEntry, FakeCreateCommand>(c => c.Data)
            .Should().BeEquivalentTo(creationResult);
        }
        public void Constructor_Always_CreatesFailedWithoutEntry()
        {
            var result = new CreationResult <DummyEntry>();

            result.Entry.Should().BeNull();
            result.Errors.Should().BeEmpty();
        }
        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));
        }
        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);
        }
        public void ShouldCreateInvalidResult()
        {
            var result = CreationResult <ResultForTest, ErrorForTest> .CreateInvalidResult(
                error : ErrorForTest.AnyError
                );

            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(result.Error, ErrorForTest.AnyError);
        }
        public void ShouldReturnsErrorWhenPasswordDoesNotContainAtLeastOfOneSymbol()
        {
            var password = "******";

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

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

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

            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(result.Error, Error.InvalidFormat);
        }
        public void ShouldReturnsErrorWhenPasswordDoesNotContainAtLeastOfOneUpperCaseLetter()
        {
            var password = "******";

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

            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(result.Error, Error.InvalidFormat);
        }
        public void ShouldReturnsErrorWhenPasswordLenghtIsLowerThan8()
        {
            var password = "******";

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

            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(result.Error, Error.InvalidFormat);
        }
        public void ShouldCreatesValidPasswords()
        {
            var password = "******";

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

            Assert.IsTrue(result.IsValid);
            Assert.AreEqual(result.Result.Value, password);
        }
        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);
        }
        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));
        }
        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);
        }
        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);
        }