Ejemplo n.º 1
0
        public void Repository_Get()
        {
            //Arrange
            var id = Guid.NewGuid();

            EventStorage.Get(id, -1, "employees")
            .Returns(
                new List <Event>()
            {
                new EmployeeCreatedEvent(55, "Alejandro", "Molines", new DateTime(1981, 11, 28), "Developer")
            }
                );

            //Act
            var user = _eventRepository.Get <Employee>(id).Result;


            //Assert
            user.EmployeeId.Should().Be(55);
            user.FirstName.Should().Be("Alejandro");
            user.LastName.Should().Be("Molines");
            user.JobTitle.Should().Be("Developer");
            user.DateOfBirth.Should().Be(28.November(1981));
            EventStorage.Received(1).Get(id, -1, "employees");
        }
Ejemplo n.º 2
0
        public void Repository_Save()
        {
            //Arrange
            var id = Guid.NewGuid();

            EventStorage.Save(Arg.Do <IEnumerable <Event> >(e => e.Any(i => i.Version == 1 && i.AggregateId.Equals(id))), "employees")
            .Returns(Task.CompletedTask);


            var employee = new Employee(id, 55, "Alejandro", "Molines", new DateTime(1981, 11, 28), "Developer");

            //Act
            _eventRepository.Save <Employee>(employee).Wait();


            //Assert
            EventStorage.Received(1).Save(Arg.Do <IEnumerable <Event> >(e => e.Any(i => i.Version == 1 && i.AggregateId.Equals(id))), "employees");
        }