Esempio n. 1
0
 public async Task CreateProfile_TooLongName_ThrowsException()
 {
     await Assert.ThrowsAsync <InvalidCommandException>(async() =>
                                                        await CommandsExecutor.Execute(
                                                            new CreateOrUpdateUserProfileCommand(AuthId, Mail, new string('a', StringLengths.Short + 1), LastName,
                                                                                                 BirthDate)));
 }
Esempio n. 2
0
        public async Task FileExportFileImport_TreeWithTwoPeople_PeoplePropertiesAreImported()
        {
            var tree = await PrepareTreeWithTwoPeople();

            var export =
                await QueriesExecutor.Execute(new GetTreeFileExportQuery(AuthId, new TreeId(tree.TreeId)));

            const string createdTreeName = "Drzewko 🍑";
            var          document        = new Document(export, "text/xml", "Drzewko");
            var          importTreeId    = await CommandsExecutor.Execute(new CreateTreeFromFileCommand(AuthId, Mail, document, createdTreeName));

            var importedTree = await QueriesExecutor.Execute(new GetTreeQuery(AuthId, importTreeId));


            Assert.Equal(createdTreeName, importedTree.TreeName);

            var princeExpected = tree.People.First(p => p.Gender == Gender.Male);
            var queenExpected  = tree.People.First(p => p.Gender != Gender.Male);
            var prince         = tree.People.First(p => p.Gender == Gender.Male);
            var queen          = tree.People.First(p => p.Gender != Gender.Male);

            AssertPersonFieldsEqual(princeExpected, prince);
            AssertPersonFieldsEqual(queenExpected, queen);

            Assert.Equal(queen.Id, prince.Mother);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            TaskScheduler.UnobservedTaskException      += TaskScheduler_UnobservedTaskException;
            AppDomain.CurrentDomain.UnhandledException += (s, e) =>
            {
                Console.WriteLine((e.ExceptionObject as Exception).Message);
            };
            var teamcityConfig = new Rest.TeamCity.ConfigurationProvider();
            var restClient     = new RestClient(
                teamcityConfig.Host,
                teamcityConfig.Login,
                teamcityConfig.Password,
                MediaType.Json);
            var tc               = new TeamCityApi(restClient);
            var gateway          = new Gateway(new[] { tc });
            var presenterFactory = new PresenterFactory();
            var output           = new Output(
                presenterFactory,
                new IOutputStream[] {
                new ConsoleStream(),
                new FileStream("log.txt")
            });
            var cancellationSource = new CancellationTokenSource();

            output.Write("build bot greetings you");
            output.Write("type exit to leave bot");

            var client   = new TelegramBotClient(new ConfigurationProvider().ApiKey);
            var commands = new List <CommandBase>
            {
                new StartCommand(cancellationSource),
                new ExitCommand(cancellationSource),
                new TeamcityGetBuildQueueCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityGetProjectsCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityGetProjectCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityGetBranchesCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityGetBuildsCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityGetBuildTypesCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityGetBuildCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityGetAgentsCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityEnqueueBuild(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityGetRunningBuildsCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityEnqueueAgentCommand(gateway.For <ITeamCity>(), cancellationSource),
                new TeamcityGetBranchCommand(gateway.For <ITeamCity>(), cancellationSource)
            };
            var help = new HelpCommand(commands, cancellationSource);

            commands.Add(help);
            var commandsExecutor = new CommandsExecutor(commands);
            var inputStream      = new InputPipeline();
            var consoleListener  = new ConsoleCommandProducer(inputStream);
            var runLooper        = new RunLooper(inputStream, commandsExecutor, consoleListener, output, cancellationSource);
            var store            = new MemoryStore();

            using (var botWrapper = new BotWrapper(client, inputStream, presenterFactory, cancellationSource, commandsExecutor, output, store))
            {
                botWrapper.Start();
                runLooper.Run();
            }
        }
        public void ExecuteCommands_OnlyFilesProcessed()
        {
            var fs = new MockFileSystem(new Dictionary <string, MockFileData>()
            {
                { @"c:\dir1\file1.txt", new MockFileData("data") },
                { @"c:\dir1\_file2.txt", new MockFileData("data") },
                { @"c:\dir2\file1.txt", new MockFileData("data") },
                { @"c:\dir2\_file2.txt", new MockFileData("data") },
                { @"c:\dir1\files", new MockDirectoryData() },
                { @"c:\dir2\_files", new MockDirectoryData() },
            }
                                        );
            var cmd = ExecuteCommands_SetupCommand();

            var executor = new CommandsExecutor(fs, cmd);

            executor.ExecuteCommands();

            Assert.True(fs.FileExists(@"c:\dir1\file1.txt"));
            Assert.True(fs.FileExists(@"c:\dir2\file1.txt"));

            Assert.True(fs.FileExists(@"c:\dir1\file2.txt"));
            Assert.True(fs.FileExists(@"c:\dir2\file2.txt"));

            Assert.True(fs.Directory.Exists(@"c:\dir1\files"));
            Assert.True(fs.Directory.Exists(@"c:\dir2\_files"));
        }
Esempio n. 5
0
        private async Task AddPersonsMainPhoto_HappyPath_FileIsReturnedInQuery()
        {
            _applicationFixture.FileSaver
            .UploadFile(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <Stream>(), Arg.Any <CancellationToken>())
            .Returns(_uriExample);

            var fileId = await CommandsExecutor.Execute(
                new AddOrChangePersonsPhotoCommand(AuthId, _treeId, new Document(Stream.Null, "image/jpeg", "jeden"), _queenId));

            Assert.NotNull(fileId);

            var tree = await QueriesExecutor.Execute(
                new GetTreeQuery(AuthId, _treeId));

            var fileFromQueryId = tree.People.FirstOrDefault()?.MainPhoto;

            Assert.Equal(fileId.Id.Value, fileFromQueryId?.Id);
            Assert.Equal("jeden", fileFromQueryId?.Name);


            var fileId2 = await CommandsExecutor.Execute(
                new AddOrChangePersonsPhotoCommand(AuthId, _treeId, new Document(Stream.Null, "image/jpeg", "dwa"), _queenId));

            var tree2 = await QueriesExecutor.Execute(
                new GetTreeQuery(AuthId, _treeId));

            var fileFromQueryId2 = tree2.People.FirstOrDefault()?.MainPhoto;

            Assert.Equal(fileId2.Id.Value, fileFromQueryId2?.Id);
            Assert.Equal("dwa", fileFromQueryId2?.Name);
        }
 protected Task PingDevice(string deviceId)
 {
     return(CommandsExecutor.ExecuteCommand((command) => DevicesService.Ping(command), new PingCommand
     {
         TargetDeviceId = deviceId
     }, timeoutInSeconds: 15));
 }
        private async Task ProcessCommand(
            InternalCommandDto internalCommand)
        {
            var     type             = _internalCommandsMapper.GetType(internalCommand.Type);
            dynamic commandToProcess = JsonConvert.DeserializeObject(internalCommand.Data, type);

            await CommandsExecutor.Execute(commandToProcess);
        }
Esempio n. 8
0
 public RunLooper(InputPipeline inputPipeline, CommandsExecutor context, ConsoleCommandProducer consoleCommandProducer, Output output, CancellationTokenSource cancellationTokenSource)
 {
     _inputPipeline          = inputPipeline;
     _context                = context;
     _consoleCommandProducer = consoleCommandProducer;
     _output = output;
     _cancellationTokenSource = cancellationTokenSource;
 }
        protected async Task <TreeId> CreateTree()
        {
            await CommandsExecutor.Execute(
                new CreateOrUpdateUserProfileCommand(AuthId, Mail, Name, LastName, BirthDate));

            return(await CommandsExecutor.Execute(
                       new CreateTreeCommand(TreeName, AuthId, Mail)));
        }
        private async Task ProcessCommand(
            InternalCommandDto internalCommand)
        {
            Type    type             = Assemblies.Application.GetType(internalCommand.Type);
            dynamic commandToProcess = JsonConvert.DeserializeObject(internalCommand.Data, type);

            await CommandsExecutor.Execute(commandToProcess);
        }
        private async Task EditMatch(MatchResponse match, Guid existingMatchId)
        {
            var date  = TryParseDate(match.dateEvent, match.strTime);
            var score = Score.CreateNew("Placeholder", TryParseInt(match.intHomeScore), TryParseInt(match.intAwayScore));

            var command = new EditMatchGeneralAttributesCommand(existingMatchId, match.strEvent, date.GetValueOrDefault(),
                                                                score, match.strSeason, "Placeholder");

            await CommandsExecutor.Execute(command);
        }
Esempio n. 12
0
        private void SendRequestBtn_Click(object sender, RoutedEventArgs e)
        {
            var executor = new CommandsExecutor(Login, Token, SimulationOrChaarr);

            result = executor.Execute(command, parameter, this.value);
            if (result != null)
            {
                UpdateInfo(result);
            }
        }
Esempio n. 13
0
        private async Task ExportFile_HappyPath_FileIsExportetAndContainsProperData()
        {
            var treeId = await CreateTree();

            var queenId = await CommandsExecutor.Execute(
                new AddPersonCommand(
                    AuthId,
                    treeId,
                    "Elżbieta",
                    "II",
                    Gender.Female,
                    new DateTime(1926, 4, 21),
                    null,
                    "Queen",
                    "Some biography"));


            var princeId = await CommandsExecutor.Execute(
                new AddPersonCommand(
                    AuthId,
                    treeId,
                    "Filip",
                    null,
                    Gender.Male,
                    new DateTime(1921, 5, 10),
                    null,
                    "Prince",
                    "Some biography of Filip",
                    new List <Relation>
            {
                new Relation(queenId, RelationDirection.FromAddedPerson, RelationType.Spouse)
            }));

            var tree = await QueriesExecutor.Execute(
                new GetTreeQuery(AuthId, treeId));

            var stream = await QueriesExecutor.Execute(
                new GetTreeFileExportQuery(AuthId, treeId));

            var serializer = new XmlSerializer(typeof(Gx.Gedcomx));

            var gedcom = (Gx.Gedcomx)serializer.Deserialize(stream);


            Assert.NotNull(gedcom);
            Assert.Equal(2, gedcom.Persons.Count);


            Assert.Single(gedcom.Persons,
                          p => p.Names.SelectMany(name => name.NameForm.Parts).Any(np => string.Equals(np.Value, "Elżbieta")));

            Assert.NotNull(gedcom.Relationships);

            Assert.Equal(RelationshipType.Couple, gedcom.Relationships.First().KnownType);
        }
Esempio n. 14
0
        private void RestartBtn_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("Your simulation will be restarted now ");
            var restarter = new CommandsExecutor(Login, Token, SimulationOrChaarr);

            result = restarter.RestartSimulation( );
            if (result != null)
            {
                UpdateInfo(result);
            }
        }
        private async Task AddMatch(MatchResponse match, TeamDto homeTeam, TeamDto awayTeam)
        {
            var date = TryParseDate(match.dateEvent, match.strTime);

            var score = Score.CreateNew("Placeholder", TryParseInt(match.intHomeScore), TryParseInt(match.intAwayScore));

            var command = new CreateMatchCommand(match.strEvent, homeTeam.Id, awayTeam.Id, date.GetValueOrDefault(), "Placeholder",
                                                 score, match.strSeason,
                                                 match.idEvent);

            await CommandsExecutor.Execute(command);
        }
Esempio n. 16
0
        private async Task <Uri> AddExampleFile(TreeId treeId)
        {
            var file = new Document(Stream.Null, "image/png", "ASDF.png");

            _applicationFixture.FileSaver
            .UploadFile(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <Stream>(),
                        Arg.Any <CancellationToken>())
            .Returns(_uriExample);

            return(await CommandsExecutor.Execute(
                       new AddOrChangeTreePhotoCommand(AuthId, treeId, file)));
        }
Esempio n. 17
0
        private static async Task ProcessCommand(InternalCommandDto internalCommand)
        {
            var type = typeof(ICustomersModule).Assembly.GetType(internalCommand.Type);

            if (null == type)
            {
                throw new ArgumentNullException(nameof(type));
            }

            dynamic commandToProcess = JsonConvert.DeserializeObject(internalCommand.Data, type);
            await CommandsExecutor.Execute(commandToProcess);
        }
Esempio n. 18
0
        public async Task AddOwner_NotOwnerAdding_ThrowsUnauthorized()
        {
            var userId = await CommandsExecutor.Execute(
                new CreateOrUpdateUserProfileCommand(AuthId, Mail, Name, LastName, BirthDate));

            var treeId = await CommandsExecutor.Execute(
                new CreateTreeCommand(TreeName, AuthId, Mail));

            _applicationFixture.UserAuthIdProvider
            .GetUserAuthId(Arg.Any <MailAddress>(), Arg.Any <CancellationToken>())
            .Returns(AuthId + "2");

            await Assert.ThrowsAsync <UnauthorizedException>(async() => await CommandsExecutor.Execute(
                                                                 new AddTreeOwnerCommand(AuthId + "2", treeId, "*****@*****.**")));
        }
Esempio n. 19
0
        private async Task Init()
        {
            _treeId = await CreateTree();

            _queenId = await CommandsExecutor.Execute(
                new AddPersonCommand(
                    AuthId,
                    _treeId,
                    "Elżbieta",
                    "II",
                    Gender.Female,
                    new DateTime(1926, 4, 21),
                    null,
                    "Queen",
                    "Some biography"));
        }
Esempio n. 20
0
        public async Task AddPersonToTree_HappyPath_PeopleAreAdded()
        {
            var treeId = await CreateTree();

            var queenId = await CommandsExecutor.Execute(
                new AddPersonCommand(
                    AuthId,
                    treeId,
                    "Elżbieta",
                    "II",
                    Gender.Female,
                    new DateTime(1926, 4, 21),
                    null,
                    "Queen",
                    "Some biography"));


            var princeId = await CommandsExecutor.Execute(
                new AddPersonCommand(
                    AuthId,
                    treeId,
                    "Filip",
                    null,
                    Gender.Male,
                    new DateTime(1921, 5, 10),
                    null,
                    "Prince",
                    "Some biography of Filip",
                    new List <Relation>
            {
                new Relation(queenId, RelationDirection.FromAddedPerson, RelationType.Spouse)
            }));

            var tree = await QueriesExecutor.Execute(
                new GetTreeQuery(AuthId, treeId));

            Assert.Equal(2, tree.People.Count);
            Assert.NotNull(tree.People.FirstOrDefault()?.Spouse);
            Assert.Null(tree.People.FirstOrDefault()?.Mother);
            Assert.Null(tree.People.FirstOrDefault()?.Father);

            Assert.Equal(TreeName, tree.TreeName);
            Assert.Equal(treeId.Value, tree.TreeId);
        }
Esempio n. 21
0
        private async Task RemovePersonsFile_HappyPath_FileIsDeleted()
        {
            _applicationFixture.FileSaver
            .UploadFile(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <Stream>(), Arg.Any <CancellationToken>())
            .Returns(_uriExample);

            var file = await CommandsExecutor.Execute(
                new AddPersonsFileCommand(AuthId, _treeId, new Document(Stream.Null, "image/jpeg", "file"), _queenId));

            await CommandsExecutor.Execute(
                new RemovePersonsFileCommand(AuthId, _treeId, file.Id, _queenId));

            var tree = await QueriesExecutor.Execute(
                new GetTreeQuery(AuthId, _treeId));

            var files = tree.People.FirstOrDefault()?.Files;

            Assert.NotNull(files);
            Assert.Empty(files);
        }
        public async Task PlaceOrder_Test()
        {
            string      customerEmail = "*****@*****.**";
            CustomerDto customer      =
                await CommandsExecutor.Execute(new RegisterCustomerCommand(customerEmail, "Sample Customer"));

            List <ProductDto> products = new List <ProductDto>();
            Guid productId             = Guid.Parse("9DB6E474-AE74-4CF5-A0DC-BA23A42E2566");

            products.Add(new ProductDto(productId, 2));
            Guid orderId = await CommandsExecutor.Execute(new PlaceCustomerOrderCommand(customer.Id, products, "EUR"));

            OrderDetailsDto orderDetails = await QueriesExecutor.Execute(new GetCustomerOrderDetailsQuery(orderId));

            Assert.That(orderDetails, Is.Not.Null);
            Assert.That(orderDetails.Value, Is.EqualTo(70));
            Assert.That(orderDetails.Products.Count, Is.EqualTo(1));
            Assert.That(orderDetails.Products[0].Quantity, Is.EqualTo(2));
            Assert.That(orderDetails.Products[0].Id, Is.EqualTo(productId));

            SqlConnection           connection   = new SqlConnection(ConnectionString);
            List <OutboxMessageDto> messagesList = await OutboxMessagesHelper.GetOutboxMessages(connection);

            Assert.That(messagesList.Count, Is.EqualTo(3));

            CustomerRegisteredNotification customerRegisteredNotification =
                OutboxMessagesHelper.Deserialize <CustomerRegisteredNotification>(messagesList[0]);

            Assert.That(customerRegisteredNotification.CustomerId, Is.EqualTo(new CustomerId(customer.Id)));

            OrderPlacedNotification orderPlaced =
                OutboxMessagesHelper.Deserialize <OrderPlacedNotification>(messagesList[1]);

            Assert.That(orderPlaced.OrderId, Is.EqualTo(new OrderId(orderId)));

            PaymentCreatedNotification paymentCreated =
                OutboxMessagesHelper.Deserialize <PaymentCreatedNotification>(messagesList[2]);

            Assert.That(paymentCreated, Is.Not.Null);
        }
Esempio n. 23
0
        public async Task CreateProfileAndTreeAddTreeOwner_HappyPath_AddsTreeOwner()
        {
            var userId = await CommandsExecutor.Execute(
                new CreateOrUpdateUserProfileCommand(AuthId, Mail, Name, LastName, BirthDate));

            var treeId = await CommandsExecutor.Execute(
                new CreateTreeCommand(TreeName, AuthId, Mail));

            var userId2 = await CommandsExecutor.Execute(
                new CreateOrUpdateUserProfileCommand(AuthId + "2", Mail, Name + "2", LastName + "2", BirthDate));


            _applicationFixture.UserAuthIdProvider
            .GetUserAuthId(Arg.Any <MailAddress>(), Arg.Any <CancellationToken>())
            .Returns(AuthId + "2");

            await CommandsExecutor.Execute(
                new AddTreeOwnerCommand(AuthId, treeId, "*****@*****.**"));

            await CommandsExecutor.Execute(
                new RemoveTreeOwnerCommand(AuthId + "2", treeId, userId));
        }
Esempio n. 24
0
        public async Task PlaceOrder_Test()
        {
            var customerEmail = "*****@*****.**";
            var customer      = await CommandsExecutor.Execute(new RegisterCustomerCommand(customerEmail, "soheil bijavar"));

            List <ProductDto> products = new List <ProductDto>();
            var productId = Guid.Parse("cdd19ddd-647a-4af7-9f95-cfef9e346c40");

            products.Add(new ProductDto(productId, 2));
            var orderId = await CommandsExecutor.Execute(new PlaceCustomerOrderCommand(customer.Id, products, "Rial"));

            var orderDetails = await QueriesExecutor.Execute(new GetCustomerOrderDetailsQuery(orderId));

            Assert.That(orderDetails, Is.Not.Null);
            Assert.That(orderDetails.Value, Is.EqualTo(80));
            Assert.That(orderDetails.Products.Count, Is.EqualTo(1));
            Assert.That(orderDetails.Products[0].Quantity, Is.EqualTo(2));
            Assert.That(orderDetails.Products[0].Id, Is.EqualTo(productId));

            var connection   = new SqlConnection(ConnectionString);
            var messagesList = await OutboxMessagesHelper.GetOutboxMessages(connection);

            Assert.That(messagesList.Count, Is.EqualTo(3));

            var customerRegisteredNotification =
                OutboxMessagesHelper.Deserialize <CustomerRegisteredNotification>(messagesList[0]);

            Assert.That(customerRegisteredNotification.CustomerId, Is.EqualTo(new CustomerId(customer.Id)));

            var orderPlaced =
                OutboxMessagesHelper.Deserialize <OrderPlacedNotification>(messagesList[1]);

            Assert.That(orderPlaced.OrderId, Is.EqualTo(new OrderId(orderId)));

            var paymentCreated =
                OutboxMessagesHelper.Deserialize <PaymentCreatedNotification>(messagesList[2]);

            Assert.That(paymentCreated, Is.Not.Null);
        }
        public async Task <Unit> Handle(ProcessInternalCommandsCommand command, CancellationToken cancellationToken)
        {
            var connection = this._sqlConnectionFactory.GetOpenConnection();

            const string sql = "SELECT " +
                               "[Command].[Type], " +
                               "[Command].[Data] " +
                               "FROM [payments].[InternalCommands] AS [Command] " +
                               "WHERE [Command].[ProcessedDate] IS NULL";
            var commands = await connection.QueryAsync <InternalCommandDto>(sql);

            var internalCommandsList = commands.AsList();

            foreach (var internalCommand in internalCommandsList)
            {
                Type type             = Assembly.GetExecutingAssembly().GetType(internalCommand.Type);
                var  commandToProcess = JsonConvert.DeserializeObject(internalCommand.Data, type) as ICommand;

                await CommandsExecutor.Execute(commandToProcess);
            }

            return(Unit.Value);
        }
Esempio n. 26
0
        public async Task <Unit> Handle(ProcessInternalCommandsCommand command, CancellationToken cancellationToken)
        {
            IDbConnection connection = _sqlConnectionFactory.GetOpenConnection();

            const string sql = "SELECT " +
                               "[Command].[Type], " +
                               "[Command].[Data] " +
                               "FROM [app].[InternalCommands] AS [Command] " +
                               "WHERE [Command].[ProcessedDate] IS NULL";
            IEnumerable <InternalCommandDto> commands = await connection.QueryAsync <InternalCommandDto>(sql);

            List <InternalCommandDto> internalCommandsList = commands.AsList();

            foreach (InternalCommandDto internalCommand in internalCommandsList)
            {
                Type?   type             = Assemblies.Application.GetType(internalCommand.Type);
                dynamic commandToProcess = JsonConvert.DeserializeObject(internalCommand.Data, type);

                await CommandsExecutor.Execute(commandToProcess);
            }

            return(Unit.Value);
        }
Esempio n. 27
0
        public async Task RegisterCustomerTest()
        {
            const string email = "*****@*****.**";
            const string name  = "soheil bijavar company";

            var customer = await CommandsExecutor.Execute(new RegisterCustomerCommand(email, name));

            var customerDetails = await QueriesExecutor.Execute(new GetCustomerDetailsQuery(customer.Id));

            Assert.That(customerDetails, Is.Not.Null);
            Assert.That(customerDetails.Name, Is.EqualTo(name));
            Assert.That(customerDetails.Email, Is.EqualTo(email));

            var connection   = new SqlConnection(ConnectionString);
            var messagesList = await OutboxMessagesHelper.GetOutboxMessages(connection);

            Assert.That(messagesList.Count, Is.EqualTo(1));

            var customerRegisteredNotification =
                OutboxMessagesHelper.Deserialize <CustomerRegisteredNotification>(messagesList[0]);

            Assert.That(customerRegisteredNotification.CustomerId, Is.EqualTo(new CustomerId(customer.Id)));
        }
Esempio n. 28
0
        private async Task <TreeDto> PrepareTreeWithTwoPeople()
        {
            var treeId = await CreateTree();

            var queenId = await CommandsExecutor.Execute(
                new AddPersonCommand(
                    AuthId,
                    treeId,
                    "Elżbieta",
                    "II",
                    Gender.Unknown,
                    new DateTime(1926, 4, 21),
                    null,
                    "Queen",
                    "Some biography"));


            var princeId = await CommandsExecutor.Execute(
                new AddPersonCommand(
                    AuthId,
                    treeId,
                    "Filip",
                    null,
                    Gender.Male,
                    new DateTime(1921, 5, 10),
                    null,
                    "Prince",
                    "Some biography of Filip",
                    new List <Relation>
            {
                new Relation(queenId, RelationDirection.FromAddedPerson, RelationType.Mother)
            }));

            return(await QueriesExecutor.Execute(
                       new GetTreeQuery(AuthId, treeId)));
        }
Esempio n. 29
0
        public async Task CreateProfileAndTree_HappyPath_TreeIsCreated()
        {
            var userId = await CommandsExecutor.Execute(
                new CreateOrUpdateUserProfileCommand(AuthId, Mail, Name, LastName, BirthDate));

            var treeId = await CommandsExecutor.Execute(
                new CreateTreeCommand(TreeName, AuthId, Mail));

            var myTrees = await QueriesExecutor.Execute(
                new GetMyTreesQuery(AuthId));

            Assert.Single(myTrees.Trees);

            var tree = myTrees.Trees[0];

            Assert.Equal(tree.Id, treeId.Value);
            Assert.Equal(TreeName, tree.TreeName);


            var treeQuery = await QueriesExecutor.Execute(
                new GetTreeQuery(AuthId, treeId));

            Assert.Equal(userId.Value, treeQuery.Owners.FirstOrDefault()?.Id);
        }
 public async Task Execute(IJobExecutionContext context)
 {
     await CommandsExecutor.Execute(new ProcessOutboxCommand());
 }