Esempio n. 1
0
        public void ETagsProvidedWillBeUsedAndStored()
        {
            var store = new AzureCollectionStore <TestCollectionEntityConcurrencyAware>(ConnectionString);
            var id    = Guid.NewGuid().ToString("N");
            var t     = new TestCollectionEntityConcurrencyAware()
            {
                Id           = id,
                Name         = "Tommy Shooter",
                ETag         = "\"1234\"",
                LastModofied = DateTimeOffset.UtcNow.AddHours(1)
            };

            store.InsertAsync(t).Wait();
            var entity = store.GetAsync(id).Result;

            Assert.Equal(t.ETag, entity.ETag);
        }
        public async Task CannotBeDeletedForConcurrencyAwareWhenETagInConflict()
        {
            var store = new AzureCollectionStore <TestCollectionEntityConcurrencyAware>(ConnectionString);
            var id    = Guid.NewGuid().ToString("N");
            var t     = new TestCollectionEntityConcurrencyAware()
            {
                Id           = id,
                Name         = "Tommy Shooter",
                ETag         = "1234",
                LastModified = DateTimeOffset.UtcNow
            };
            await store.InsertAsync(t);

            t.Name = "The Fall";
            t.ETag = "4567";

            await Assert.ThrowsAsync <AggregateException>(() => store.DeleteAsync(t));
        }
Esempio n. 3
0
        public void CannotBeUpdatedForConcurrencyAwareWhenETagInConflict()
        {
            var store = new AzureCollectionStore <TestCollectionEntityConcurrencyAware>(ConnectionString);
            var id    = Guid.NewGuid().ToString("N");
            var t     = new TestCollectionEntityConcurrencyAware()
            {
                Id           = id,
                Name         = "Tommy Shooter",
                ETag         = "\"1234\"",
                LastModofied = DateTimeOffset.UtcNow
            };

            store.InsertAsync(t).Wait();

            t.Name = "The Fall";
            t.ETag = "\"8998\"";

            Assert.Throws <AggregateException>(() => store.UpsertAsync(t).Wait());
        }
Esempio n. 4
0
        public void CanBeUpdatedForConcurrencyAware()
        {
            var store = new AzureCollectionStore <TestCollectionEntityConcurrencyAware>(ConnectionString);
            var id    = Guid.NewGuid().ToString("N");
            var t     = new TestCollectionEntityConcurrencyAware()
            {
                Id           = id,
                Name         = "Tommy Shooter",
                ETag         = "\"1234\"",
                LastModofied = DateTimeOffset.UtcNow
            };

            store.InsertAsync(t).Wait();
            t.Name = "The Fall";
            store.UpsertAsync(t).Wait();

            var t2 = store.GetAsync(id).Result;

            Assert.Equal("The Fall", t2.Name);
        }
        public async Task CanBeUpdatedForConcurrencyAware()
        {
            var store = new AzureCollectionStore <TestCollectionEntityConcurrencyAware>(ConnectionString);
            var id    = Guid.NewGuid().ToString("N");
            var t     = new TestCollectionEntityConcurrencyAware()
            {
                Id           = id,
                Name         = "Tommy Shooter",
                ETag         = "W/\"1234798h88787\"",
                LastModified = DateTimeOffset.UtcNow
            };
            await store.InsertAsync(t);

            t.Name = "The Fall";
            var tr = await store.GetAsync(id);

            await store.UpsertAsync(tr);

            var t2 = await store.GetAsync(id);

            Assert.Equal("The Fall", t2.Name);
        }
Esempio n. 6
0
        public void CanBeUpdatedForConcurrencyAware()
        {
            var store = new AzureCollectionStore<TestCollectionEntityConcurrencyAware>(ConnectionString);
            var id = Guid.NewGuid().ToString("N");
            var t = new TestCollectionEntityConcurrencyAware()
            {
                Id = id,
                Name = "Tommy Shooter",
                ETag = "\"1234\"",
                LastModofied = DateTimeOffset.UtcNow 
            };
            store.InsertAsync(t).Wait();
            t.Name = "The Fall";
            store.UpsertAsync(t).Wait();

            var t2 = store.GetAsync(id).Result;
            Assert.Equal("The Fall", t2.Name);
        }
Esempio n. 7
0
        public void CannotBeDeletedForConcurrencyAwareWhenETagInConflict()
        {
            var store = new AzureCollectionStore<TestCollectionEntityConcurrencyAware>(ConnectionString);
            var id = Guid.NewGuid().ToString("N");
            var t = new TestCollectionEntityConcurrencyAware()
            {
                Id = id,
                Name = "Tommy Shooter",
                ETag = "1234",
                LastModofied = DateTimeOffset.UtcNow
            };
            store.InsertAsync(t).Wait();

            t.Name = "The Fall";
            t.ETag = "4567";

            Assert.Throws<AggregateException>(() => store.DeleteAsync(t).Wait());
        }
Esempio n. 8
0
 public void ETagsProvidedWillBeUsedAndStored()
 {
     var store = new AzureCollectionStore<TestCollectionEntityConcurrencyAware>(ConnectionString);
     var id = Guid.NewGuid().ToString("N");
     var t = new TestCollectionEntityConcurrencyAware()
     {
         Id = id,
         Name = "Tommy Shooter",
         ETag = "\"1234\"",
         LastModofied = DateTimeOffset.UtcNow.AddHours(1)
     };
     store.InsertAsync(t).Wait();
     var entity = store.GetAsync(id).Result;
     Assert.Equal(t.ETag, entity.ETag);
 }