public void Init() { this.ConfigureMappings(); this._context = new FakePetHomeContext(); this.foundPets = new List <FoundPet>() { new FoundPet() { Id = 1, AnimalType = AnimalType.Cat, AssociatedUser = null, Breed = "Lion", IsLostPet = false, LastSeenLocation = "South Park", LastSeenTime = DateTime.Today, ActionTaken = "Nothing" }, new FoundPet() { Id = 2, AnimalType = AnimalType.Rodent, AssociatedUser = null, Breed = "Hedgehog", IsLostPet = false, LastSeenLocation = "West Park", LastSeenTime = DateTime.Today, ActionTaken = "Nothing" } }; foreach (var pet in foundPets) { this._context.FoundPets.Add(pet); } // var fakeHttpContext = new Mock <HttpContextBase>(); var fakeIdentity = new GenericIdentity("User"); var principal = new GenericPrincipal(fakeIdentity, new string[] { "Admin" }); fakeHttpContext.Setup(t => t.User).Returns(principal); var controllerContext = new Mock <ControllerContext>(); controllerContext.Setup(t => t.HttpContext).Returns(fakeHttpContext.Object); this._service = new FoundPetsService(this._context); this._controller = new FoundPetsController(this._service); this._controller.ControllerContext = controllerContext.Object; }
public FoundPetsController(IFoundPetsService service) { this.service = service; }