コード例 #1
0
        public async Task Return_sequence0_if_event_stream_is_empty()
        {
            await Make.TestFile("sequence0.es").AndExecute(async env => {
                var store = new FileEventStoreWithCache(new CustomJsonSerializer(), env.FilePath);

                var lastSequence = await store.GetLastSequence("test");
                lastSequence.Should().Be(-1);
            });
        }
コード例 #2
0
 public async Task Save_SpendingAdded_in_csv_file()
 {
     await Make.TestFile("SpendingAdded.es").AndExecute(async env =>
     {
         var store = new FileEventStoreWithCache(new CustomJsonSerializer(), env.FilePath);
         await store.Save(new SpendingAdded(OperationId.From(5), Amount.From(15.2), Label.From("this is a test"), Pair.First, SpendingCategory.Advance));
         var @event = await store.GetEvents(a => true);
         @event.Last().Should().BeOfType <SpendingAdded>().Which.OperationId.Should().Be(OperationId.From(5));
     });
 }
コード例 #3
0
        public async Task Save_PeriodCreated_in_csv_file()
        {
            await Make.TestFile("period.es").AndExecute(async environment =>
            {
                var store = new FileEventStoreWithCache(new CustomJsonSerializer(), environment.FilePath);

                await store.Save(new PeriodCreated(PeriodName.From(1, 2017)));

                var @event = await store.GetEvents(b => true);
                @event.Last().Should().BeOfType <PeriodCreated>().Which.PeriodName.Should().Be(PeriodName.From(1, 2017));
            });
        }
コード例 #4
0
        public async Task Throw_exception_if_blank_username(string firstUsername, string secondUsername, string operatorUsername)
        {
            await Make.TestFile("blankname.config").AndExecute(environment =>
            {
                CreateConfigFile(environment.FilePath, firstUsername: firstUsername, secondUsername: secondUsername, operatorUsername: operatorUsername);

                Action action = () => new XmlUserProvider(environment.FilePath);
                action.Should().Throw <EmptyConfigurationUsernameException>();

                return(Task.CompletedTask);
            });
        }
コード例 #5
0
        public async Task Throw_exception_if_blank_password(string firstPassword, string secondPassword, string operatorPassword)
        {
            await Make.TestFile("blankpassword.config").AndExecute(environment =>
            {
                CreateConfigFile(environment.FilePath, firstUserPassword: firstPassword, secondUserPassword: secondPassword, operatorPassword: operatorPassword);

                Action action = () => new XmlUserProvider(environment.FilePath);
                action.Should().Throw <EmptyConfigurationPasswordException>();

                return(Task.CompletedTask);
            });
        }
コード例 #6
0
        public async Task Create_empty_config_file_and_throw_exception_when_config_not_exists()
        {
            await Make.TestFile("TestUser.config").AndExecute(environment =>
            {
                Action action = () => new XmlUserProvider(environment.FilePath);

                action.Should().Throw <FileNotFoundException>();
                File.Exists(environment.FilePath).Should().BeTrue();
                new FileInfo(environment.FilePath).Length.Should().BePositive();

                return(Task.CompletedTask);
            });
        }
コード例 #7
0
        public async Task Reload_all_events_with_their_domainEvent_infos()
        {
            await Make.TestFile("reload.es").AndExecute(async env =>
            {
                var store = new FileEventStoreWithCache(new CustomJsonSerializer(), env.FilePath);

                var period = Period.Create(PeriodName.From(1, 2007));
                period.AddSpending(Amount.From(5), Label.From("test"), Pair.First, SpendingCategory.Common);
                await store.Save(period.UncommittedEvents.GetStream());

                var store2 = new FileEventStoreWithCache(new CustomJsonSerializer(), env.FilePath);

                var allEvents = await store2.GetEvents(a => true);
                allEvents.Any(a => a.AggregateId.IsEmpty()).Should().BeFalse();
            });
        }
コード例 #8
0
        public async Task Crypt_password_if_stored_in_plain_text(string allPassword, string expected)
        {
            await Make.TestFile("password.config").AndExecute(environment =>
            {
                CreateConfigFile(environment.FilePath, firstUserPassword: allPassword, secondUserPassword: allPassword, operatorPassword: allPassword);

                var _ = new XmlUserProvider(environment.FilePath);

                var config = Xml.DeserializeFrom <WalletMateConfiguration>(environment.FilePath);
                config.FirstPair.Password.Should().Be(expected);
                config.SecondPair.Password.Should().Be(expected);
                config.Operator.Password.Should().Be(expected);

                return(Task.CompletedTask);
            });
        }
コード例 #9
0
        public async Task Retrieve_last_sequence()
        {
            await Make.TestFile("Sequence.es").AndExecute(async env =>
            {
                var store = new FileEventStoreWithCache(new CustomJsonSerializer(), env.FilePath);

                var period = Period.Create(PeriodName.From(1, 2007));
                period.AddSpending(Amount.From(5), Label.From("test"), Pair.First, SpendingCategory.Common);
                period.AddSpending(Amount.From(5), Label.From("test2"), Pair.First, SpendingCategory.Common);
                period.AddSpending(Amount.From(5), Label.From("test3"), Pair.First, SpendingCategory.Common);
                period.AddSpending(Amount.From(5), Label.From("test4"), Pair.First, SpendingCategory.Common);

                await store.Save(period.UncommittedEvents.GetStream());

                var lastSequence = await store.GetLastSequence(period.AggregateId);
                lastSequence.Should().Be(8);
            });
        }
コード例 #10
0
        public async Task Write_in_eventstore_from_multiple_thread()
        {
            await Make.TestFile("MultiThread.es").AndExecute(async env =>
            {
                var store = new FileEventStoreWithCache(new CustomJsonSerializer(), env.FilePath);

                var period = Period.Create(PeriodName.From(1, 2007));
                period.AddSpending(Amount.From(5), Label.From("test"), Pair.First, SpendingCategory.Common);
                period.AddSpending(Amount.From(5), Label.From("test2"), Pair.First, SpendingCategory.Common);
                period.AddSpending(Amount.From(5), Label.From("test3"), Pair.First, SpendingCategory.Common);
                period.AddSpending(Amount.From(5), Label.From("test4"), Pair.First, SpendingCategory.Common);

                var t1 = Task.Run(() => store.Save(period.UncommittedEvents.GetStream()));
                var t2 = Task.Run(() => store.Save(period.UncommittedEvents.GetStream()));

                Task.WaitAll(t1, t2);

                var lastSequence = await store.GetLastSequence(period.AggregateId);
                lastSequence.Should().Be(8);
            });
        }
コード例 #11
0
        public async Task Return_users_with_decoded_password_hash(string allPassword, string expected)
        {
            await Make.TestFile("blankname.config").AndExecute(environment =>
            {
                CreateConfigFile(environment.FilePath, firstUserPassword: allPassword, secondUserPassword: allPassword, operatorPassword: allPassword);
                var provider = new XmlUserProvider(environment.FilePath);

                provider.GetUsers()
                .Select(a => a.Password)
                .ToList()
                .Should()
                .HaveCount(3)
                .And
                .BeEquivalentTo(
                    new List <string>()
                {
                    expected, expected, expected
                });

                return(Task.CompletedTask);
            });
        }