Ejemplo n.º 1
0
        [Fact] public void ToGrainModel_ShouldTransferAllFields()
        {
            var original = new IncomingUser();
            var expected = new User();

            original.UserId       = expected.UserId = Guid.NewGuid();
            original.DisplayName  = expected.DisplayName = "Joe Bloggs";
            original.EmailAddress = expected.EmailAddress = "*****@*****.**";

            original.ToGrainModel().Should().BeEquivalentTo(expected,
                                                            "because we expect all fields to be transferred");
        }
        public void Find_ShouldReturnGrainModel()
        {
            var stored = new IncomingUser {
                UserId = Guid.NewGuid()
            };

            _unitOfWork.Setup(u => u.Users.Get(stored.UserId))
            .Returns(() => Task.FromResult <IUser>(stored));

            var grain = Silo.CreateGrain <UserGrain>(stored.UserId);

            grain.Find().GetAwaiter().GetResult().Should().BeEquivalentTo(stored.ToGrainModel(),
                                                                          "becuase that's what the UnitOfWork provided");

            _unitOfWork.Verify(u => u.Users.Get(stored.UserId), Times.Once(),
                               "because we need to call it just once");

            _unitOfWork.VerifyNoOtherCalls();
        }