public void GetPollByIdNotFound()
        {
            var command = new GetByIdQueryHandler(_pollRepositorioMock.Object);

            var result = command.Handle(new GetByIdQuery(2), new CancellationToken()).Result;

            Assert.AreEqual(0, result.Poll_id);
            Assert.AreEqual(null, result.Poll_description);
        }
        public void GetPollByIdSuccessAsync()
        {
            var command = new GetByIdQueryHandler(_pollRepositorioMock.Object);

            var result = command.Handle(new GetByIdQuery(1), new CancellationToken()).Result;

            Assert.NotNull(result);
            Assert.AreNotEqual(0, result.Poll_id);
            Assert.AreEqual(_pollMock.FirstOrDefault().PollDescription, result.Poll_description);
        }
        public void Insert_and_return_by_id()
        {
            Guid id;
            using (var db = new PragmaticDbContext())
            {
                var newPerson = new Person { Name = "Han Solo"};
                id = newPerson.Id;

                db.Persons.Add(newPerson);
                db.SaveChanges();
            }

            Option<Person> person = new GetByIdQueryHandler<Person>(new PragmaticDbContext())
                .Execute(new GetByIdQuery<Person> { Id = id });

            Assert.IsTrue(person.IsSome);
            Assert.AreEqual("Han Solo", person.Value.Name);
        }
        public void Insert_and_return_by_id_as_object()
        {
            Guid id;
            using (var db = new PragmaticDbContext())
            {
                var newPerson = new Person { Name = "Han Solo" };
                id = newPerson.Id;

                db.Persons.Add(newPerson);
                db.SaveChanges();
            }

            Option<object> person = new GetByIdQueryHandler(new PragmaticDbContext())
                .Execute(new GetByIdQuery{ EntityType = typeof(Person), EntityId = id });

            Assert.IsTrue(person.IsSome);
            Assert.That(person.Value.GetType(), Is.EqualTo(typeof(Person)));
            Assert.AreEqual("Han Solo", ((Person)person.Value).Name);
        }