Ejemplo n.º 1
0
        public async Task IdentifiableQuerySaveAndLoad(PersistenceLayerProvider layerProvider)
        {
            var queryRepository = layerProvider.ReadModelRepository;

            var guid       = Guid.NewGuid();
            var testQuerry = new TestReadModel {
                Identity = guid.ToString()
            };

            testQuerry.SetVars("Test", new[] { "Jeah", "jeah2" });
            await queryRepository.SaveReadModelAsync(testQuerry);

            var querry1 = await queryRepository.LoadAsync <TestReadModel>(guid);

            Assert.AreEqual(guid.ToString(), querry1.Value.Identity);
            Assert.AreEqual("Test", querry1.Value.UserName);
            Assert.AreEqual("Jeah", querry1.Value.Strings.First());
        }
Ejemplo n.º 2
0
        public async Task IdentifiableQuerySaveAndLoadAll_UnknownType(PersistenceLayerProvider layerProvider)
        {
            var queryRepository = layerProvider.ReadModelRepository;

            var testQuerry = new TestReadModel {
                Identity = Guid.NewGuid().ToString()
            };
            var testQuerry2 = new TestReadModel {
                Identity = Guid.NewGuid().ToString()
            };

            testQuerry.SetVars("Test", new[] { "Jeah", "jeah2" });
            testQuerry2.SetVars("Test", new[] { "Jeah", "jeah2" });
            await queryRepository.SaveReadModelAsync(testQuerry);

            await queryRepository.SaveReadModelAsync(testQuerry2);

            var loadAll = await queryRepository.LoadAllAsync <TestReadModel2>();

            Assert.IsTrue(!loadAll.Value.Any());
        }
Ejemplo n.º 3
0
        public async Task InsertReadModelDifferentTypeButSameId(PersistenceLayerProvider layerProvider)
        {
            var queryRepository = layerProvider.ReadModelRepository;

            var guidstring = Guid.NewGuid();
            var testRm1    = new TestReadModel {
                Identity = guidstring.ToString()
            };
            var testRm2 = new TestReadModel2 {
                Identity = guidstring.ToString()
            };

            await queryRepository.SaveReadModelAsync(testRm1);

            await queryRepository.SaveReadModelAsync(testRm2);

            var res1 = await queryRepository.LoadAsync <TestReadModel>(guidstring.ToString());

            var res2 = await queryRepository.LoadAsync <TestReadModel2>(guidstring.ToString());

            Assert.IsNotNull(res1.Value);
            Assert.IsNotNull(res2.Value);
        }