public void Get_Normally_ShouldReturn_PartnerWithId()
        {
            Partner createdPartner, queriedPartner;

            using (var dataLayer = DataLayerHelper.CreateDataLayer())
                using (var controller = new PartnersController(dataLayer))
                {
                    createdPartner = controller.CreatePartner(TestDataProvider.CreateNewPartner());
                    queriedPartner = controller.Get(createdPartner.Id);
                }

            Assert.IsTrue(
                queriedPartner.IsEqualTo(createdPartner),
                "The two partners should be equal. "
                + $"Expected: {createdPartner.Stringify()}, actual: {queriedPartner.Stringify()}.");
        }
        public void Update_Normally_ShouldWork()
        {
            Partner createdPartner, updatedPartner;

            using (var dataLayer = DataLayerHelper.CreateDataLayer())
                using (var controller = new PartnersController(dataLayer))
                {
                    createdPartner = controller.CreatePartner(TestDataProvider.CreateNewPartner());
                    controller.Update(new PartnerUpdate {
                        Id = createdPartner.Id, Name = "Eleanor Rigby", Address = "Liverpool"
                    });
                    updatedPartner = controller.Get(createdPartner.Id);
                }

            Assert.AreEqual("Eleanor Rigby", updatedPartner.Name);
            Assert.AreEqual("Liverpool", updatedPartner.Address);
        }
        public void Delete_Normally_ShouldWork()
        {
            Partner createdPartner, queriedPartner;
            IEnumerable <Partner> listedPartners;

            using (var dataLayer = DataLayerHelper.CreateDataLayer())
                using (var controller = new PartnersController(dataLayer))
                {
                    createdPartner = controller.CreatePartner(TestDataProvider.CreateNewPartner());
                    queriedPartner = controller.Get(createdPartner.Id);
                    controller.Delete(createdPartner.Id);
                    listedPartners = controller.List();
                }

            Assert.AreEqual(createdPartner.Id, queriedPartner.Id, "Unexpected ID.");
            Assert.AreEqual(false, listedPartners.Any(), "There should be no partners returned.");
        }
 public void Get_WhenRecordDoesNotExist_ShouldThrow()
 {
     using (var dataLayer = DataLayerHelper.CreateDataLayer())
         using (var controller = new PartnersController(dataLayer))
             controller.Get(0);
 }