Exemple #1
0
        public void AggregateShouldBeValidWhenLoadedWithExistentSnapshotAndNewEvents()
        {
            EventBus              eventBus;
            EventStore            eventStore;
            SnapshotStore         snapshotStore;
            SnapshotProcessor     snapshotProcessor;
            InMemorySnapshotStore memorySnapshotStore;
            var repository = EnvironmentMock.CreateEnvironment <TestSnapshotAggregate>(out eventBus, out eventStore,
                                                                                       out snapshotStore, out snapshotProcessor, out memorySnapshotStore, 3);

            var guid = Guid.NewGuid();

            repository.Save(new TestSnapshotAggregate(guid, "Test Snapshot Aggregate v0"), -1);

            var aggregate = repository.GetById(guid);

            aggregate.ChangeName("Test Snapshot Aggregate v1");
            aggregate.ChangeName("Test Snapshot Aggregate v2");
            aggregate.ChangeName("Test Snapshot Aggregate v3 (Snapshot)");

            repository.Save(aggregate, 0);

            const string name        = "Test Snapshot Aggregate v4";
            var          aggregateV4 = repository.GetById(guid);

            aggregateV4.ChangeName(name);
            repository.Save(aggregateV4, 3);

            repository.GetById(guid).ReturnNameForTest().Should().Be(name);
        }
        public void ItShouldReturnManifestsFromTestHook()
        {
            Initialize();

            string sdkVersion = "5.0.100";

            var additionalManifestDirectory = Path.Combine(_testDirectory, "AdditionalManifests");

            Directory.CreateDirectory(additionalManifestDirectory);

            var environmentMock = new EnvironmentMock();

            environmentMock.Add(EnvironmentVariableNames.WORKLOAD_MANIFEST_ROOTS, additionalManifestDirectory);

            //  Manifest in test hook directory
            Directory.CreateDirectory(Path.Combine(additionalManifestDirectory, sdkVersion, "Android"));
            File.WriteAllText(Path.Combine(additionalManifestDirectory, sdkVersion, "Android", "WorkloadManifest.json"), "AndroidContent");

            //  Manifest in default directory
            Directory.CreateDirectory(Path.Combine(_manifestDirectory, "iOS"));
            File.WriteAllText(Path.Combine(_manifestDirectory, "iOS", "WorkloadManifest.json"), "iOSContent");


            var sdkDirectoryWorkloadManifestProvider
                = new SdkDirectoryWorkloadManifestProvider(sdkRootPath: _fakeDotnetRootDirectory, sdkVersion: sdkVersion, environmentMock.GetEnvironmentVariable);

            GetManifestContents(sdkDirectoryWorkloadManifestProvider)
            .Should()
            .BeEquivalentTo("AndroidContent", "iOSContent");
        }
Exemple #3
0
        public void EventStoreShouldThrowConcurrencyExceptionWhenExpectedVersionIsWrong()
        {
            EventBus   eventBus;
            EventStore eventStore;
            var        repository = EnvironmentMock.CreateEnvironment <TestAggregate>(out eventBus, out eventStore);

            var guid = Guid.NewGuid();

            repository.Save(new TestAggregate(guid, "Test Aggregate 1"), -1);

            var expectedVersion = TestDatabase.Items[guid].OriginalVersion;

            var loadedAggregate = repository.GetById(guid);

            loadedAggregate.ChangeName("New test Aggregate 1");

            repository.Save(loadedAggregate, expectedVersion);

            var newLoadedAggregate = repository.GetById(guid);

            newLoadedAggregate.ChangeName("Newer test Aggregate 1");

            Action act = () => repository.Save(newLoadedAggregate, expectedVersion);

            act.ShouldThrow <ConcurrencyException>();
        }
Exemple #4
0
        public void RepositoryShouldLoadAndSave20000AggregatesWithSnapShotsEnabledIn60Seconds()
        {
            EventBus              eventBus;
            EventStore            eventStore;
            SnapshotStore         snapshotStore;
            SnapshotProcessor     snapshotProcessor;
            InMemorySnapshotStore memorySnapshotStore;
            var repository = EnvironmentMock.CreateEnvironment <TestSnapshotAggregate>(out eventBus, out eventStore,
                                                                                       out snapshotStore, out snapshotProcessor, out memorySnapshotStore, 100);

            var guid = Guid.NewGuid();

            repository.Save(new TestSnapshotAggregate(guid, "Test Snapshot Aggregate v0"), -1);

            Action act = () =>
            {
                for (var i = 1; i <= 19999; i++)
                {
                    var aggregate = repository.GetById(guid);
                    aggregate.ChangeName("Test Snapshot Aggregate v" + i);
                    repository.Save(aggregate, i - 1);
                }
            };

            act.ExecutionTime().ShouldNotExceed(new TimeSpan(0, 0, 60));
        }
Exemple #5
0
        public void SnapshotProcesserIsSnapshotNeededShouldReturnCorrectValuesWhenMultipleEventsAreCommittedAtOnce()
        {
            EventBus              eventBus;
            EventStore            eventStore;
            SnapshotStore         snapshotStore;
            SnapshotProcessor     snapshotProcessor;
            InMemorySnapshotStore memorySnapshotStore;
            var repository = EnvironmentMock.CreateEnvironment <TestSnapshotAggregate>(out eventBus, out eventStore,
                                                                                       out snapshotStore, out snapshotProcessor, out memorySnapshotStore, 3);

            var guid = Guid.NewGuid();

            repository.Save(new TestSnapshotAggregate(guid, "Test Snapshot Aggregate v0"), -1);

            var aggregate = repository.GetById(guid);

            aggregate.ChangeName("Test Snapshot Aggregate v1");
            aggregate.ChangeName("Test Snapshot Aggregate v2");
            aggregate.ChangeName("Test Snapshot Aggregate v3 (Snapshot)");
            aggregate.ChangeName("Test Snapshot Aggregate v4");
            aggregate.ChangeName("Test Snapshot Aggregate v5");
            aggregate.ChangeName("Test Snapshot Aggregate v6 (Snapshot)");
            aggregate.ChangeName("Test Snapshot Aggregate v7");
            aggregate.ChangeName("Test Snapshot Aggregate v8");
            aggregate.ChangeName("Test Snapshot Aggregate v9 (Snapshot)");
            repository.Save(aggregate, 0);

            aggregate.GetSnapshot().Version.Should().Be(9);
            memorySnapshotStore.All().Count().Should().Be(1);
        }
Exemple #6
0
        public void SnapshotProcesserIsSnapshotNeededShouldReturnTrueWhenThreasholdIsExceeded()
        {
            EventBus              eventBus;
            EventStore            eventStore;
            SnapshotStore         snapshotStore;
            SnapshotProcessor     snapshotProcessor;
            InMemorySnapshotStore memorySnapshotStore;
            var repository = EnvironmentMock.CreateEnvironment <TestSnapshotAggregate>(out eventBus, out eventStore,
                                                                                       out snapshotStore, out snapshotProcessor, out memorySnapshotStore, 3);

            var guid = Guid.NewGuid();

            repository.Save(new TestSnapshotAggregate(guid, "Test Snapshot Aggregate v0"), -1);

            var aggregate = repository.GetById(guid);

            aggregate.ChangeName("Test Snapshot Aggregate v1");
            aggregate.ChangeName("Test Snapshot Aggregate v2");
            aggregate.ChangeName("Test Snapshot Aggregate v3 (Snapshot)");
            repository.Save(aggregate, 0);

            snapshotProcessor.IsSnapshotNeeded(guid, typeof(TestSnapshotAggregate), 5).Should().BeFalse();
            //Because aggregate version stays 3, every new aggregate version needs a snapshot
            snapshotProcessor.IsSnapshotNeeded(guid, typeof(TestSnapshotAggregate), 6).Should().BeTrue();
            snapshotProcessor.IsSnapshotNeeded(guid, typeof(TestSnapshotAggregate), 7).Should().BeTrue();
            snapshotProcessor.IsSnapshotNeeded(guid, typeof(TestSnapshotAggregate), 8).Should().BeTrue();
            snapshotProcessor.IsSnapshotNeeded(guid, typeof(TestSnapshotAggregate), 9).Should().BeTrue();
        }
Exemple #7
0
        public void VersionOfAggregatesShouldBeIndependentlyIncreased()
        {
            EventBus   eventBus;
            EventStore eventStore;
            var        repository = EnvironmentMock.CreateEnvironment <TestAggregate>(out eventBus, out eventStore);

            var guid1 = Guid.NewGuid();
            var guid2 = Guid.NewGuid();

            repository.Save(new TestAggregate(guid1, "Test Aggregate 1"), -1);
            repository.Save(new TestAggregate(guid2, "Test Aggregate 2"), -1);

            var expectedVersion1 = TestDatabase.Items[guid1].OriginalVersion;
            var expectedVersion2 = TestDatabase.Items[guid2].OriginalVersion;

            var loadedAggregate1 = repository.GetById(guid1);

            loadedAggregate1.ChangeName("New test Aggregate 1");
            repository.Save(loadedAggregate1, expectedVersion1);

            eventStore.GetEventsByAggregateId(guid1)
            .OrderByDescending(e => e.Version)
            .FirstOrDefault()
            .Version.Should()
            .Be(expectedVersion1 + 1);
            eventStore.GetEventsByAggregateId(guid2)
            .OrderByDescending(e => e.Version)
            .FirstOrDefault()
            .Version.Should()
            .Be(expectedVersion2);
        }
        public void ManifestFromTestHookShouldOverrideDefault()
        {
            Initialize();

            var additionalManifestDirectory = Path.Combine(_testDirectory, "AdditionalManifests");

            Directory.CreateDirectory(additionalManifestDirectory);

            var environmentMock = new EnvironmentMock();

            environmentMock.Add("DOTNETSDK_WORKLOAD_MANIFEST_ROOTS", additionalManifestDirectory);

            //  Manifest in test hook directory
            Directory.CreateDirectory(Path.Combine(additionalManifestDirectory, "Android"));
            File.WriteAllText(Path.Combine(additionalManifestDirectory, "Android", "WorkloadManifest.json"), "OverridingAndroidContent");

            //  Manifest in default directory
            Directory.CreateDirectory(Path.Combine(_manifestDirectory, "Android"));
            File.WriteAllText(Path.Combine(_manifestDirectory, "Android", "WorkloadManifest.json"), "OverriddenAndroidContent");

            var sdkDirectoryWorkloadManifestProvider
                = new SdkDirectoryWorkloadManifestProvider(sdkRootPath: _fakeDotnetRootDirectory, sdkVersion: "5.0.100", environmentMock.GetEnvironmentVariable);

            GetManifestContents(sdkDirectoryWorkloadManifestProvider)
            .Should()
            .BeEquivalentTo("OverridingAndroidContent");
        }
Exemple #9
0
        // Analysis disable once InconsistentNaming
        public void GetUserCacheDir_ReturnsHome_WhenXdgCacheHomeNotSet()
        {
            var environment = new EnvironmentMock("HOME", "/home/user");
            var xdg         = new XdgDirectoryService(null, environment.Object);

            var result = xdg.GetUserCacheDir();

            Assert.AreEqual("/home/user/.cache", result);
        }
Exemple #10
0
        // Analysis disable once InconsistentNaming
        public void GetUserCacheDir_ReturnsXdgCacheHome_WhenXdgCacheHomeSet()
        {
            var environment = new EnvironmentMock("XDG_CACHE_HOME", "/path/to/.cache");
            var xdg         = new XdgDirectoryService(null, environment.Object);

            var result = xdg.GetUserCacheDir();

            Assert.AreEqual("/path/to/.cache", result);
        }
Exemple #11
0
        // Analysis disable once InconsistentNaming
        public void GethThumbnailsDir_ReturnsFolderForNormalThumbnails()
        {
            var environment = new EnvironmentMock("XDG_CACHE_HOME", "/path/to/.cache");
            var xdg         = new XdgDirectoryService(null, environment.Object);

            var result = xdg.GetThumbnailsDir(ThumbnailSize.Normal);

            Assert.AreEqual("/path/to/.cache/thumbnails/normal", result);
        }
Exemple #12
0
        // Analysis disable once InconsistentNaming
        public void GethThumbnailsDir_ReturnsFolderForNormalThumbnails()
        {
            var environment = new EnvironmentMock("XDG_CACHE_HOME", pathToCache);
            var xdg         = new XdgDirectoryService(null, environment.Object);

            var result = xdg.GetThumbnailsDir(ThumbnailSize.Normal);

            Assert.AreEqual(Path.Combine("path", "to", ".cache", "thumbnails", "normal"), result);
        }
        public void RepositoryShouldReturnNewAggregateIfItWasntSavedBefore()
        {
            EventBus   eventBus;
            EventStore eventStore;
            var        repository = EnvironmentMock.CreateEnvironment <TestAggregate>(out eventBus, out eventStore);

            var guid = Guid.NewGuid();

            repository.GetById(guid).Should().NotBeNull();
            repository.GetById(guid).Id.Should().Be(Guid.Empty);
        }
Exemple #14
0
        // Analysis disable once InconsistentNaming
        public void GetUserCacheDir_ReturnsXdgCacheHome_WhenXdgCacheHomeAndHomeAreSet()
        {
            var environment = new EnvironmentMock("XDG_CACHE_HOME", pathToCache);

            environment.SetVariable("HOME", homeDir);
            var xdg = new XdgDirectoryService(null, environment.Object);

            var result = xdg.GetUserCacheDir();

            Assert.AreEqual(pathToCache, result);
        }
Exemple #15
0
        // Analysis disable once InconsistentNaming
        public void GetUserCacheDir_ReturnsCachedValue_WhenXdgCacheHomeIsChanged()
        {
            var environment = new EnvironmentMock("XDG_CACHE_HOME", "/first/path/.cache");
            var xdg         = new XdgDirectoryService(null, environment.Object);

            xdg.GetUserCacheDir();
            environment.SetVariable("XDG_CACHE_HOME", "/second/path/.cache");

            var result = xdg.GetUserCacheDir();

            Assert.AreEqual("/first/path/.cache", result);
        }
Exemple #16
0
        public void VersionOfAggregateShouldBePublishedByEventByStore()
        {
            EventBus   eventBus;
            EventStore eventStore;
            var        repository = EnvironmentMock.CreateEnvironment <TestAggregate>(out eventBus, out eventStore);

            var guid = Guid.NewGuid();

            repository.Save(new TestAggregate(guid, "Test Aggregate 1"), -1);

            TestDatabase.Items[guid].OriginalVersion.Should().Be(0);
        }
        public void RepositoryShouldPersistEventToEventStoreWhenAggregateWasSaved()
        {
            EventBus   eventBus;
            EventStore eventStore;
            var        repository = EnvironmentMock.CreateEnvironment <TestAggregate>(out eventBus, out eventStore);

            var guid      = Guid.NewGuid();
            var aggregate = new TestAggregate(guid, String.Empty);

            repository.Save(aggregate, -1);

            eventStore.GetEventsByAggregateId(guid).Count().Should().Be(1);
        }
Exemple #18
0
        public void VersionOfAggregateCreateEventShouldBeZero()
        {
            EventBus   eventBus;
            EventStore eventStore;
            var        repository = EnvironmentMock.CreateEnvironment <TestAggregate>(out eventBus, out eventStore);

            var guid      = Guid.NewGuid();
            var aggregate = new TestAggregate(guid, "Test Aggregate 1");

            repository.Save(aggregate, -1);

            eventStore.GetEventsByAggregateId(guid).FirstOrDefault().Version.Should().Be(0);
        }
Exemple #19
0
        public void SnapshotProcesserIsSnapshotNeededShouldCorrectlyCalculateThreasholdIntervalsWhenAggregateVersionIsIncreased()
        {
            EventBus              eventBus;
            EventStore            eventStore;
            SnapshotStore         snapshotStore;
            SnapshotProcessor     snapshotProcessor;
            InMemorySnapshotStore memorySnapshotStore;
            var repository = EnvironmentMock.CreateEnvironment <TestSnapshotAggregate>(out eventBus, out eventStore,
                                                                                       out snapshotStore, out snapshotProcessor, out memorySnapshotStore, 3);

            var guid = Guid.NewGuid();

            repository.Save(new TestSnapshotAggregate(guid, "Test Snapshot Aggregate v0"), -1);

            var aggregate = repository.GetById(guid);

            aggregate.ChangeName("Test Snapshot Aggregate v1");
            aggregate.ChangeName("Test Snapshot Aggregate v2");
            aggregate.ChangeName("Test Snapshot Aggregate v3 (Snapshot)");
            repository.Save(aggregate, 0);

            aggregate.ChangeName("Test Snapshot Aggregate v4");
            repository.Save(aggregate, 3);

            aggregate.ChangeName("Test Snapshot Aggregate v5");
            repository.Save(aggregate, 4);

            snapshotProcessor.IsSnapshotNeeded(guid, typeof(TestSnapshotAggregate), 5).Should().BeFalse();
            snapshotProcessor.IsSnapshotNeeded(guid, typeof(TestSnapshotAggregate), 6).Should().BeTrue(); // Needed because last snapshot version is 3

            aggregate.ChangeName("Test Snapshot Aggregate v6 (Snapshot)");
            repository.Save(aggregate, 5);

            snapshotProcessor.IsSnapshotNeeded(guid, typeof(TestSnapshotAggregate), 6).Should().BeFalse(); //Not needed because snapshot was taken of v5

            aggregate.ChangeName("Test Snapshot Aggregate v7");
            repository.Save(aggregate, 6);

            snapshotProcessor.IsSnapshotNeeded(guid, typeof(TestSnapshotAggregate), 7).Should().BeFalse();

            aggregate.ChangeName("Test Snapshot Aggregate v8");
            repository.Save(aggregate, 7);

            snapshotProcessor.IsSnapshotNeeded(guid, typeof(TestSnapshotAggregate), 8).Should().BeFalse();
            snapshotProcessor.IsSnapshotNeeded(guid, typeof(TestSnapshotAggregate), 9).Should().BeTrue(); // Needed because last snapshot version is 6

            aggregate.ChangeName("Test Snapshot Aggregate v9 (snapshot)");
            repository.Save(aggregate, 8);

            snapshotProcessor.IsSnapshotNeeded(guid, typeof(TestSnapshotAggregate), 9).Should().BeFalse(); //Not needed because snapshot was taken of v9
        }
Exemple #20
0
        public void RepositoryShouldThrowExceptionIfNotSupported()
        {
            EventBus              eventBus;
            EventStore            eventStore;
            SnapshotStore         snapshotStore;
            SnapshotProcessor     snapshotProcessor;
            InMemorySnapshotStore memorySnapshotStore;
            var repository = EnvironmentMock.CreateEnvironment <TestAggregate>(out eventBus, out eventStore,
                                                                               out snapshotStore, out snapshotProcessor, out memorySnapshotStore, 3);

            Action act = () => repository.GetOriginator(Guid.NewGuid());

            act.ShouldThrow <SnapshotNotSupportedException>();
        }
Exemple #21
0
        // Analysis disable once InconsistentNaming
        public void GetUserCacheDir_ReturnsTempPath_WhenXdgCacheHomeAndHomeNotSet()
        {
            var environment = EnvironmentMock.Create("user");
            var fileSystem  = new Mock <IFileSystem> {
                DefaultValue = DefaultValue.Mock
            };
            var path     = fileSystem.Object.Path;
            var pathMock = Mock.Get(path);

            pathMock.Setup(p => p.GetTempPath()).Returns("/temp/path");

            var result = new XdgDirectoryService(fileSystem.Object, environment).GetUserCacheDir();

            Assert.AreEqual("/temp/path/user/.cache", result);
        }
        public void RepositoryShouldReturnPreviouslySavedAggregate()
        {
            EventBus   eventBus;
            EventStore eventStore;
            var        repository = EnvironmentMock.CreateEnvironment <TestAggregate>(out eventBus, out eventStore);

            var          guid      = Guid.NewGuid();
            const string name      = "Initial Aggregate Name";
            var          aggregate = new TestAggregate(guid, String.Empty);

            aggregate.ChangeName(name);

            repository.Save(aggregate, -1);

            repository.GetById(guid).ReturnNameForTest().Should().Be(name);
        }
        public void RepositorySaveShouldMarkAllAggregateChangesAsCommitted()
        {
            EventBus   eventBus;
            EventStore eventStore;
            var        repository = EnvironmentMock.CreateEnvironment <TestAggregate>(out eventBus, out eventStore);

            var          guid      = Guid.NewGuid();
            const string name      = "Initial Aggregate Name";
            var          aggregate = new TestAggregate(guid, String.Empty);

            aggregate.ChangeName(name);

            repository.Save(aggregate, -1);

            repository.GetById(guid).HasPendingChanges().Should().Be(false);
        }
        public void RepositorySaveShouldInitiateEventHandlersToUpdateReadModel()
        {
            EventBus   eventBus;
            EventStore eventStore;
            var        repository = EnvironmentMock.CreateEnvironment <TestAggregate>(out eventBus, out eventStore);

            var          guid      = Guid.NewGuid();
            const string name      = "Initial Aggregate Name";
            var          aggregate = new TestAggregate(guid, String.Empty);

            aggregate.ChangeName(name);

            repository.Save(aggregate, -1);

            TestDatabase.Items[guid].Name.Should().Be(name);
        }
Exemple #25
0
        public void SnapshotProcessorShouldNotCreateSnapshotIfAggregateDoesntSupportThis()
        {
            EventBus              eventBus;
            EventStore            eventStore;
            SnapshotStore         snapshotStore;
            SnapshotProcessor     snapshotProcessor;
            InMemorySnapshotStore memorySnapshotStore;

            EnvironmentMock.CreateEnvironment <TestAggregate>(out eventBus, out eventStore,
                                                              out snapshotStore, out snapshotProcessor, out memorySnapshotStore);

            var guid = Guid.NewGuid();

            snapshotProcessor.CreateSnapshot(guid, typeof(TestAggregate));

            memorySnapshotStore.Find(guid).Should().BeEmpty();
        }
        public void ItSupportsMultipleTestHookFolders()
        {
            Initialize();

            string sdkVersion = "5.0.100";

            var additionalManifestDirectory1 = Path.Combine(_testDirectory, "AdditionalManifests1");

            Directory.CreateDirectory(additionalManifestDirectory1);
            var additionalManifestDirectory2 = Path.Combine(_testDirectory, "AdditionalManifests2");

            Directory.CreateDirectory(additionalManifestDirectory2);

            var environmentMock = new EnvironmentMock();

            environmentMock.Add(EnvironmentVariableNames.WORKLOAD_MANIFEST_ROOTS, additionalManifestDirectory1 + Path.PathSeparator + additionalManifestDirectory2);


            //  Manifests in default directory
            Directory.CreateDirectory(Path.Combine(_manifestDirectory, "iOS"));
            File.WriteAllText(Path.Combine(_manifestDirectory, "iOS", "WorkloadManifest.json"), "iOSContent");

            Directory.CreateDirectory(Path.Combine(_manifestDirectory, "Android"));
            File.WriteAllText(Path.Combine(_manifestDirectory, "Android", "WorkloadManifest.json"), "DefaultAndroidContent");

            //  Manifests in first additional directory
            Directory.CreateDirectory(Path.Combine(additionalManifestDirectory1, sdkVersion, "Android"));
            File.WriteAllText(Path.Combine(additionalManifestDirectory1, sdkVersion, "Android", "WorkloadManifest.json"), "AndroidContent1");

            //  Manifests in second additional directory
            Directory.CreateDirectory(Path.Combine(additionalManifestDirectory2, sdkVersion, "Android"));
            File.WriteAllText(Path.Combine(additionalManifestDirectory2, sdkVersion, "Android", "WorkloadManifest.json"), "AndroidContent2");

            Directory.CreateDirectory(Path.Combine(additionalManifestDirectory2, sdkVersion, "Test"));
            File.WriteAllText(Path.Combine(additionalManifestDirectory2, sdkVersion, "Test", "WorkloadManifest.json"), "TestContent2");

            var sdkDirectoryWorkloadManifestProvider
                = new SdkDirectoryWorkloadManifestProvider(sdkRootPath: _fakeDotnetRootDirectory, sdkVersion: sdkVersion, environmentMock.GetEnvironmentVariable);

            GetManifestContents(sdkDirectoryWorkloadManifestProvider)
            .Should()
            .BeEquivalentTo("AndroidContent1", "iOSContent", "TestContent2");
        }
Exemple #27
0
        public void SnapshotProcessorShouldNotCreateSnapshotBeforeThresholdIsReached()
        {
            EventBus              eventBus;
            EventStore            eventStore;
            SnapshotStore         snapshotStore;
            SnapshotProcessor     snapshotProcessor;
            InMemorySnapshotStore memorySnapshotStore;
            var repository = EnvironmentMock.CreateEnvironment <TestSnapshotAggregate>(out eventBus, out eventStore,
                                                                                       out snapshotStore, out snapshotProcessor, out memorySnapshotStore, 3);

            var guid      = Guid.NewGuid();
            var aggregate = new TestSnapshotAggregate(guid, "Test Snapshot Aggregate v0");

            aggregate.ChangeName("Test Snapshot Aggregate v1");

            repository.Save(aggregate, -1);

            memorySnapshotStore.Find(guid).Should().BeEmpty();
        }
        public void IfTestHookFolderDoesNotExistItShouldBeIgnored()
        {
            Initialize();

            var additionalManifestDirectory = Path.Combine(_testDirectory, "AdditionalManifests");

            var environmentMock = new EnvironmentMock();

            environmentMock.Add(EnvironmentVariableNames.WORKLOAD_MANIFEST_ROOTS, additionalManifestDirectory);

            //  Manifest in default directory
            Directory.CreateDirectory(Path.Combine(_manifestDirectory, "Android"));
            File.WriteAllText(Path.Combine(_manifestDirectory, "Android", "WorkloadManifest.json"), "AndroidContent");

            var sdkDirectoryWorkloadManifestProvider
                = new SdkDirectoryWorkloadManifestProvider(sdkRootPath: _fakeDotnetRootDirectory, sdkVersion: "5.0.100", environmentMock.GetEnvironmentVariable);

            GetManifestContents(sdkDirectoryWorkloadManifestProvider)
            .Should()
            .BeEquivalentTo("AndroidContent");
        }
Exemple #29
0
        public void VersionOfAggregateShouldBeIncreatedWithNewAddedEvents()
        {
            EventBus   eventBus;
            EventStore eventStore;
            var        repository = EnvironmentMock.CreateEnvironment <TestAggregate>(out eventBus, out eventStore);

            var guid = Guid.NewGuid();

            repository.Save(new TestAggregate(guid, "Test Aggregate 1"), -1);

            var expectedVersion = TestDatabase.Items[guid].OriginalVersion;

            var loadedAggregate = repository.GetById(guid);

            loadedAggregate.ChangeName("New test Aggregate 1");
            repository.Save(loadedAggregate, expectedVersion);

            eventStore.GetEventsByAggregateId(guid)
            .OrderByDescending(e => e.Version)
            .FirstOrDefault()
            .Version.Should()
            .Be(expectedVersion + 1);
        }