Beispiel #1
0
        public void FindById_Finds()
        {
            var sprocket = new Sprocket {
                Id = Guid.NewGuid(), Name = "FindMe"
            };

            SprocketCollection.Insert(sprocket);
            SprocketRepo.Find(sprocket.Id).Name.Should().Be("FindMe");
        }
Beispiel #2
0
        public void Delete_Removes()
        {
            var sprocket = new Sprocket {
                Id = Guid.NewGuid(), Name = "DeleteMe"
            };

            SprocketCollection.Insert(sprocket);
            SprocketRepo.Delete(sprocket.Id);
            SprocketCollection.FindAll().Count(s => s.Id == sprocket.Id).Should().Be(0);
        }
        public async Task Update(Sprocket sprocket)
        {
            var sprocketGrain = GrainFactory.GetGrain <ISprocketGrain>(Guid.Empty);
            await sprocketGrain.Update(sprocket);

            var sprockets = await sprocketGrain.GetAll();

            var replicaUpdates = _ring.Nodes
                                 .Select(x => GrainFactory.GetGrain <ISprocketReadReplicaGrain>(x).Sync(sprockets)
                                         );

            await Task.WhenAll(replicaUpdates);
        }
Beispiel #4
0
        public void Add_Inserts()
        {
            var sprocket = new Sprocket
            {
                Id        = Guid.NewGuid(),
                Name      = "Outer",
                Sprockets = new[] { new Sprocket {
                                        Id = Guid.NewGuid(), Name = "Inner"
                                    } }
            };

            SprocketRepo.Add(sprocket);

            Sprocket found = SprocketCollection.AsQueryable().Single(s => s.Id == sprocket.Id);

            found.Name.Should().Be("Outer");
            found.Sprockets.Single().Name.Should().Be("Inner");
        }
Beispiel #5
0
        public void Update_Saves()
        {
            var sprocket = new Sprocket
            {
                Id        = Guid.NewGuid(),
                Name      = "Outer",
                Sprockets = new[] { new Sprocket {
                                        Id = Guid.NewGuid(), Name = "Inner"
                                    } }
            };

            SprocketCollection.Insert(sprocket);

            sprocket      = SprocketCollection.AsQueryable().Single(s => s.Id == sprocket.Id);
            sprocket.Name = "Saved";
            SprocketRepo.Update(sprocket);

            Sprocket found = SprocketCollection.AsQueryable().Single(s => s.Id == sprocket.Id);

            found.Name.Should().Be("Saved");
        }
        public Task Update(Sprocket sprocket)
        {
            _sprockets[sprocket.Id] = sprocket;

            return(Task.CompletedTask);
        }