public SubscriptionSettingsServiceTests() { var fakeDbContext = new FakeLikkleDbContext().Seed(); this._mockedLikkleUoW = new Mock <ILikkleUoW>(); this._mockedLikkleUoW.Setup(uow => uow.AreaRepository) .Returns(new AreaRepository(fakeDbContext)); this._mockedLikkleUoW.Setup(uow => uow.UserRepository) .Returns(new UserRepository(fakeDbContext)); this._mockedLikkleUoW.Setup(uow => uow.GroupRepository) .Returns(new GroupRepository(fakeDbContext)); this._mockedLikkleUoW.Setup(uow => uow.TagRepository) .Returns(new TagRepository(fakeDbContext)); this._mockedLikkleUoW.Setup(uow => uow.LanguageRepository) .Returns(new LanguageRepository(fakeDbContext)); this._mockedConfigurationProvider = new Mock <IConfigurationProvider>(); this._subscriptionSettingsService = new SubscriptionSettingsService( this._mockedLikkleUoW.Object, this._mockedConfigurationProvider.Object); }
public UserServiceTests() { var fakeDbContext = new FakeLikkleDbContext().Seed(); this._mockedLikkleUoW = new Mock <ILikkleUoW>(); this._mockedLikkleUoW.Setup(uow => uow.AreaRepository) .Returns(new AreaRepository(fakeDbContext)); this._mockedLikkleUoW.Setup(uow => uow.UserRepository) .Returns(new UserRepository(fakeDbContext)); this._mockedLikkleUoW.Setup(uow => uow.GroupRepository) .Returns(new GroupRepository(fakeDbContext)); this._mockedLikkleUoW.Setup(uow => uow.TagRepository) .Returns(new TagRepository(fakeDbContext)); this._mockedLikkleUoW.Setup(uow => uow.LanguageRepository) .Returns(new LanguageRepository(fakeDbContext)); this._accelometerAlgorithmHelperService = new Mock <IAccelometerAlgorithmHelperService>(); this._accelometerAlgorithmHelperService.Setup( a => a.SecondsToClosestBoundary(It.IsAny <double>(), It.IsAny <double>())).Returns(32.5); this._subscriptionSettingsServiceMock = new Mock <ISubscriptionSettingsService>(); this._mockedConfigurationProvider = new Mock <IConfigurationProvider>(); var mapConfiguration = new MapperConfiguration(cfg => { cfg.AddProfile <EntitiesMappingProfile>(); }); this._mockedConfigurationProvider.Setup(mc => mc.CreateMapper()).Returns(mapConfiguration.CreateMapper); this._subscriptionSettingsService = new SubscriptionSettingsService( this._mockedLikkleUoW.Object, this._mockedConfigurationProvider.Object); this._configurationWrapperMock = new Mock <IConfigurationWrapper>(); // Only this call to the mocked service returns the actual result but not mocked one. this._subscriptionSettingsServiceMock .Setup(ss => ss.GroupsForUserAroundCoordinatesBasedOnUserSettings(It.IsAny <Guid>(), It.IsAny <double>(), It.IsAny <double>())) .Returns((Guid userId, double lat, double lon) => this._subscriptionSettingsService.GroupsForUserAroundCoordinatesBasedOnUserSettings(userId, lat, lon)); this._userService = new UserService( this._mockedLikkleUoW.Object, this._mockedConfigurationProvider.Object, this._configurationWrapperMock.Object, this._accelometerAlgorithmHelperService.Object, this._subscriptionSettingsServiceMock.Object); this._subscriptionService = new SubscriptionService( this._mockedLikkleUoW.Object, this._mockedConfigurationProvider.Object, this._configurationWrapperMock.Object); }
public UserService( ILikkleUoW uow, IConfigurationProvider configurationProvider, IConfigurationWrapper config, IAccelometerAlgorithmHelperService accelometerAlgorithmHelperService, ISubscriptionSettingsService subscriptionSettingsService) { this._unitOfWork = uow; _mapper = configurationProvider.CreateMapper(); this._configuration = config; _accelometerAlgorithmHelperService = accelometerAlgorithmHelperService; _subscriptionSettingsService = subscriptionSettingsService; }