public void Should_Return_The_Right_Collection() { var ContextMock = new AnimaniaConsoleContext(Effort.DbConnectionFactory.CreateTransient()); var LocationMock = new Mock <ILocationServices>(); var AnimalTypeMock = new Mock <IAnimalTypeServices>(); var BreedTypeMock = new Mock <IBreedTypeServices>(); postServices = new PostServices(ContextMock, LocationMock.Object, AnimalTypeMock.Object, BreedTypeMock.Object); User user = new User() { Id = 1, UserName = "******", Password = "******", Email = "*****@*****.**" }; BreedType breed = new BreedType() { BreedTypeName = "TestBreed", AnimalTypeId = 1 }; AnimalType type = new AnimalType() { AnimalTypeName = "TestAnimalTypeName", }; Location location = new Location() { LocationName = "TestLocation", }; var animal = new Animal { AnimalName = "TestAnimalTypeName", Birthday = DateTime.Now, AnimalTypeId = 1, BreedTypeId = 1, LocationId = 1, UserId = 1 }; var post = new CreatePostModel() { Title = "1234567890", Description = "12345678901234567890", Status = true, Price = 12.0M, LocationName = location.LocationName, AnimalTypeName = "TestAnimalTypeName", BreedTypeName = "TestBreed", AnimalName = "TestAnimalName", Birthday = DateTime.Now }; Assert.IsInstanceOfType(postServices.GetAllMyPosts(1), typeof(IEnumerable <PostModel>)); }
public void Initialize() { Mapper.Initialize(config => { config.CreateMap <CreatePostModel, Post>().ReverseMap(); }); locationServicesMock = new Mock <ILocationServices>(); animalTypeServicesMock = new Mock <IAnimalTypeServices>(); breedTypeServicesMock = new Mock <IBreedTypeServices>(); effortContext = new AnimaniaConsoleContext(Effort.DbConnectionFactory.CreateTransient()); postService = new PostServices(effortContext, locationServicesMock.Object, animalTypeServicesMock.Object, breedTypeServicesMock.Object); User user = new User() { UserName = "******", Password = "******", Email = "*****@*****.**" }; BreedType breed = new BreedType() { BreedTypeName = "TestBreed", AnimalTypeId = 1 }; AnimalType type = new AnimalType() { AnimalTypeName = "TestAnimalTypeName", }; Location location = new Location() { LocationName = "TestLocation", }; effortContext.Locations.Add(location); effortContext.AnimalTypes.Add(type); effortContext.BreedTypes.Add(breed); effortContext.Users.Add(user); effortContext.SaveChanges(); }