public void SetUp() { autoMocker = new RhinoAutoMocker<VotableFeatureVoter>(MockMode.AAA); expectedVotableFeature = new VotableFeature { NumberOfDownvotes = startingNumberOfDownvotes, NumberOfUpvotes = startingNumberOfUpvotes }; autoMocker.Get<IDataContext>().Expect(mock => mock.FindById<VotableFeature>(votableFeatureId)) .Return(expectedVotableFeature); }
public void SetUp() { autoMocker = new RhinoAutoMocker <VotableFeatureVoter>(MockMode.AAA); expectedVotableFeature = new VotableFeature { NumberOfDownvotes = startingNumberOfDownvotes, NumberOfUpvotes = startingNumberOfUpvotes }; autoMocker.Get <IDataContext>().Expect(mock => mock.FindById <VotableFeature>(votableFeatureId)) .Return(expectedVotableFeature); }
public void ItRetrievesTheGivenVotableFeature() { string featureId = "some feature id"; VotableFeature expectedVotableFeature = new VotableFeature(); autoMocker.Get<IDataContext>().Expect(mock => mock.FindById<VotableFeature>(featureId)) .Return(expectedVotableFeature); var actualResult = autoMocker.ClassUnderTest.RetrieveVotableFeature(featureId); Assert.That(expectedVotableFeature, Is.SameAs(actualResult)); }
// GET /api/VotableFeatures/<id> public VotableFeatureViewModel Get(string id) { try { VotableFeature votableFeature = votableFeatureRetriever.RetrieveVotableFeature(id); return(Mapper.Map <VotableFeature, VotableFeatureViewModel>(votableFeature)); } catch (EntityDoesNotExistException) { throw new HttpResponseException(HttpStatusCode.NotFound); } }
public void ItRetrievesTheGivenVotableFeature() { string featureId = "some feature id"; VotableFeature expectedVotableFeature = new VotableFeature(); autoMocker.Get <IDataContext>().Expect(mock => mock.FindById <VotableFeature>(featureId)) .Return(expectedVotableFeature); var actualResult = autoMocker.ClassUnderTest.RetrieveVotableFeature(featureId); Assert.That(expectedVotableFeature, Is.SameAs(actualResult)); }
public void Get_ReturnsTheFeatureInterestSummaryForTheGivenFeature() { string featureId = "some feature id"; VotableFeature expectedVotableFeature = new VotableFeature() { Id = featureId }; autoMocker.Get<IVotableFeatureRetriever>().Expect(mock => mock.RetrieveVotableFeature(featureId)) .Return(expectedVotableFeature); VotableFeatureViewModel expectedVotableFeatureViewModel = Mapper.Map<VotableFeature, VotableFeatureViewModel>(expectedVotableFeature); autoMocker.ClassUnderTest.Get(featureId); Assert.That(expectedVotableFeatureViewModel.Id, Is.EqualTo(featureId)); }
public void Get_ReturnsTheFeatureInterestSummaryForTheGivenFeature() { string featureId = "some feature id"; VotableFeature expectedVotableFeature = new VotableFeature() { Id = featureId }; autoMocker.Get <IVotableFeatureRetriever>().Expect(mock => mock.RetrieveVotableFeature(featureId)) .Return(expectedVotableFeature); VotableFeatureViewModel expectedVotableFeatureViewModel = Mapper.Map <VotableFeature, VotableFeatureViewModel>(expectedVotableFeature); autoMocker.ClassUnderTest.Get(featureId); Assert.That(expectedVotableFeatureViewModel.Id, Is.EqualTo(featureId)); }