public async Task GetSagaMetadataAsync_GetsFromRepo()
        {
            var sagaMetadata1 = new SagaMetadataRecord(Guid.Parse("46FA66FF-C8AC-4E24-AE74-11DAFF21D3D4"), Guid.Parse("39F01E63-CA48-463E-B9C9-F049832DE92E"));

            inMemoryCrudRepository.Attach(sagaMetadata1);

            var result = await sut.GetSagaMetadataAsync(sagaMetadata1.Id);

            result.ClassId.Should().Be(sagaMetadata1.ClassId);
        }
Beispiel #2
0
        public async Task Add_AddsToRepository()
        {
            NotificationBuffer buffer = new NotificationBuffer(Guid.NewGuid(), Guid.NewGuid(),
                                                               Guid.NewGuid());

            inMemoryCrudRepository.Attach(buffer);

            DateTimeOffset now = DateTimeOffset.Now;

            await sut.Add(new SerializedNotification()
            {
                NotificationClassName = "Notification1", NotificationJson = "{}"
            },
                          buffer.Id, now, Guid.NewGuid(), Guid.NewGuid());

            Assert.Equal(1, inMemoryCrudRepository.FindAllWithAdded <BufferedNotification>().Count());
            Assert.Single(inMemoryCrudRepository.FindAllWithAdded <BufferedNotification>(),
                          x => x.NotificationClassName == "Notification1" &&
                          x.NotificationJson == "{}" &&
                          x.Buffer == buffer &&
                          x.TimeQueued == now &&
                          x.Id != Guid.Empty);
            Assert.Equal(1, inMemoryCrudRepository.FindAll <NotificationBuffer>().Count());
        }
Beispiel #3
0
        public async Task SelectNotificationsForReleaseAsync_ReturnsAllExpiredNotifications()
        {
            FakeClock.Setup();
            FakeClock.Now = DateTime.Now;

            NotificationBuffer buffer1 = new NotificationBuffer(Guid.NewGuid(), governorId, Guid.NewGuid());

            inMemoryCrudRepository.Attach(buffer1);
            BufferedNotification notification1 = new BufferedNotification(Guid.NewGuid(), "Notification1", "{}",
                                                                          buffer1, FakeClock.Now.Subtract(TimeSpan.FromMinutes(6)));

            inMemoryCrudRepository.Attach(notification1);
            BufferedNotification notification2 = new BufferedNotification(Guid.NewGuid(), "Notification2", "{}",
                                                                          buffer1, FakeClock.Now.Subtract(TimeSpan.FromMinutes(3)));

            inMemoryCrudRepository.Attach(notification2);
            buffer1.Notifications = new List <BufferedNotification>()
            {
                notification1, notification2
            };

            NotificationBuffer buffer2 = new NotificationBuffer(Guid.NewGuid(), governorId, Guid.NewGuid());

            inMemoryCrudRepository.Attach(buffer2);
            BufferedNotification notification3 = new BufferedNotification(Guid.NewGuid(), "Notification3", "{}",
                                                                          buffer2, FakeClock.Now.Subtract(TimeSpan.FromMinutes(8)));

            inMemoryCrudRepository.Attach(notification3);
            buffer2.Notifications = new List <BufferedNotification>()
            {
                notification3
            };

            NotificationBuffer buffer3 = new NotificationBuffer(Guid.NewGuid(), governorId, Guid.NewGuid());

            inMemoryCrudRepository.Attach(buffer3);
            BufferedNotification notification4 = new BufferedNotification(Guid.NewGuid(), "Notification3", "{}",
                                                                          buffer3, FakeClock.Now.Subtract(TimeSpan.FromMinutes(1)));

            inMemoryCrudRepository.Attach(notification4);
            buffer3.Notifications = new List <BufferedNotification>()
            {
                notification4
            };

            var notifications = await sut.SelectNotificationsForReleaseAsync(inMemoryCrudRepository);

            Assert.Equal(2, notifications.Keys.Count());
            Assert.Equal(2, notifications[buffer1].Count);
            Assert.Contains(notification1, notifications[buffer1]);
            Assert.Contains(notification2, notifications[buffer1]);
            Assert.Equal(1, notifications[buffer2].Count);
            Assert.Contains(notification3, notifications[buffer2]);
        }