public ADUser Get(string email) { var adService = new AdService(); var result = adService.FindByEmail(email); return(result); }
public async Task Edit() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "Edit_Ad") .Options; var user = new AgencyProfile { Id = "agencyId", Username = "******" }; var ad = new Ad { Id = 1, Title = "AAAAAAAA" }; var adTitle = ad.Title; int count; using (var db = new ApplicationDbContext(options)) { db.AgenciesProfiles.Add(user); db.Ads.Add(ad); db.SaveChanges(); AdService service = new AdService(db); await service.EditAd(1, "Titleeeeeeeeeeeeee", "Description", "Residental", "65", "Location", "20", "A"); count = db.Ads.Count(); } Assert.NotEqual(adTitle, ad.Title); }
public async Task CreateAdTests() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "Create_Ad") .Options; IEnumerable <string> imgP = new List <string> { "aaaaa", "bbbbbb" }; var user = new AgencyProfile { Id = "agencyId", Username = "******" }; int count; using (var db = new ApplicationDbContext(options)) { db.AgenciesProfiles.Add(user); db.SaveChanges(); AdService service = new AdService(db); await service.CreateAd("Name", "Titleeeeeeeeeeeeee", "Description", imgP, "Residental", "65", "Location", "20", "A"); count = db.Ads.Count(); } Assert.Equal(1, count); }
private void DoAdActions(string action) { AdService ads = AdService.GetInstance(); if (action.Equals("AdEnable")) { string id = Request["Id"]; int r = ads.Enable(id); if (r > 0) { json = "{\"result\":1}"; } else { json = "{\"result\":0, \"msg\":\"服务器发生错误,状态改变失败!\"}"; } } else if (action.Equals("AdDelete")) { string id = Request["Id"]; try { ads.DeleteModel(id); json = "{\"result\":1}"; } catch (Exception ex) { json = "{\"result\":0, \"msg\":\"" + ex.Message + "\"}"; } } }
public void RepositoryContainsNoAds_ShouldReturnEmptyResult() { var sut = new AdService(AdRepositoryMock.Object); var result = sut.Get(OrderAdBy.Time); Assert.Empty(result); }
public ActionResult Modify() { int adId = CECRequest.GetQueryInt("Id", 0); var model = AdService.Get(adId); return(View("Create", model)); }
public ConfigurationViewModel(AdService adService) { _adService = adService; _configs = new ObservableCollection <AdConfiguration>(AdConfiguration.Configurations); _selectedConfig = AdConfiguration.CurrentConfiguration; _configDetailViewModel = new ConfigDetailViewModel(); }
public void EditAdWithWrongIdShouldRedturnNullReferenceException() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()); var carRepository = new EfDeletableEntityRepository <Car>(new ApplicationDbContext(options.Options)); var service = new AdService(carRepository); var editAd = new EditAddInputModel { Id = "fakeId", Cc = 0, Color = Color.Beige, Door = Doors.Five, EuroStandart = EuroStandart.Euro5, Extras = "asd", Fuel = Fuel.Diesel, Gearbox = Gearbox.Automatic, Hp = 2, Km = 2, Location = Location.Sofia, Make = Make.AstonMartin, Model = "tesr", Modification = "test", MoreInformation = "test", Price = 33, Type = Types.Combi, Condition = Condition.ForParts, YearOfProduction = "03.1999", TypeOfVeichle = TypeOfVeichle.All, }; Assert.ThrowsAsync <NullReferenceException>(async() => await service.EditAd(editAd)); }
public XController(IHttpContextAccessor accessor, IMemoryCache memoryCache) : base(accessor) { this.memoryCache = memoryCache; ToBuyContext context = new ToBuyContext(); service = new AdService(context); }
public MainController() { ToBuyContext context = new ToBuyContext(); cs = new CategoryService(context); ass = new AdService(context); }
public void AboveZeroId_ShouldAddToRepository() { var sut = new AdService(AdRepositoryMock.Object); sut.Delete(1); AdRepositoryMock.Verify(m => m.Delete(It.IsAny <int>())); }
public async Task DeleteAdTests() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "Delete_Ad") .Options; var ad = new Ad { Id = 1 }; int countAfterAdd; int countAfterDelete; using (var db = new ApplicationDbContext(options)) { db.Ads.Add(ad); db.SaveChanges(); countAfterAdd = db.Ads.Count(); AdService service = new AdService(db); await service.DeleteAd(ad.Id); countAfterDelete = db.Ads.Count(); } Assert.NotEqual(countAfterAdd, countAfterDelete); }
protected void Page_load(object sender, EventArgs e) { // if session user is empty then // get the logged in user // check if is in the valid ad group // if true then continue // else redirect to login page string _domain = ConfigurationManager.AppSettings.Get("domain"); string _domainController = ConfigurationManager.AppSettings.Get("domainController"); string _userGroups = ConfigurationManager.AppSettings.Get("userGroups"); if (!IsPostBack) { if (Session["UserId"] == null) { string loggedInWindowsUser = WindowsIdentity.GetCurrent().Name; if (AdService.IsInGroup(_userGroups, _domain, _domainController)) { Session["UserId"] = loggedInWindowsUser; } else { Response.Redirect("Login.aspx"); } } } }
public void CreateAds() { //Act //IFacebookClient client = new FacebookClient("2.9", "1057652130914324", "9ffc28c2a12d447cb5132995656ac92c", "client_credentials"); IFacebookClient client = new FacebookClient("2.9", "EAANOERzv1jEBAMcBC4tDSqpbb1AWfYZAj3BZCoifcMgm3yOADpVWmonpa8drpMyiP6JPf3UAdYbpM4j6NmBIhzIBlF2NyAid1ecKvWWTNXvM8cNWCZBleZCZA2EONXXczk4nFdKtz99NB52POJARZAc2ArQtYEIi8ZD"); //Service IAdService service = new AdService(client); //Create Ad ad = new Ad(); ad.Name = "Test AD"; ad.Status = JAM.Facebook.Models.Enums.Status.PAUSED; ad.AdSetId = 23842605921750113; //Post Engag ad.Creative = new AdCreative() { CreativeId = "23842605023090113" //Este creative ya existia y se habia creado anteriormente // CreativeId = "23842605023090113" //Se creo este creative pero hay que averiguar que clase de post aplica para LINK_CLICK }; var response = service.Create("10155310538728783", ad); Assert.IsNotNull(response); //Ads Create for APi: 23842605030960113 }
public void NegativeId_ShouldThrow() { var sut = new AdService(AdRepositoryMock.Object); void Act() => sut.Delete(-1); Assert.Throws <ArgumentException>(Act); }
public void ModelNull_ShouldThrow() { var sut = new AdService(AdRepositoryMock.Object); void Act() => sut.Add(null); Assert.Throws <ArgumentNullException>(Act); }
public void GetPupilsTest() { using var adService = AdService.Login(_user, _pass); var pupils = adService.GetPupils("5AHIF"); Assert.True(pupils.Length > 0); Assert.True(pupils.All(p => p.Classes.Contains("5AHIF"))); }
public void Post([FromBody] CreateTokenModel model) { //TODO: var adService = new AdService(); var valid = adService.ValidateCredentials(model.Login, model.Password); //generate token //return token }
public void EnumParserTestShouldRetunNull() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()); var carRepository = new EfDeletableEntityRepository <Car>(new ApplicationDbContext(options.Options)); var service = new AdService(carRepository); Assert.Throws <NullReferenceException>(() => service.EnumParser("Lada", "1")); Assert.Throws <IndexOutOfRangeException>(() => service.EnumParser("Audi", "100")); }
/// <summary> /// Method to unlock loaded accounts. Operates as worker thread. /// </summary> /// <param name="state">Unused paramter for transmissing state.</param> private void UnlockAccounts(object state) { // Configure access to AD. var adService = new AdService(new AdConfiguration { Server = this.config.Domain, Username = this.config.Username, Password = this.config.Password, IgnoreServerIpAddresses = this.config.IgnoreServerIpAddresses }); // Loop execution. while (!this.stopping.WaitOne(0)) { log.Debug("Beginning unlock cycle."); // Unlock accounts. foreach (var unlockAccount in this.config.UnlockAccounts) { // Wrap into try-catch block so service continues to operate regardless of errors. try { // Attempt to load user. var account = adService.GetUser(unlockAccount); // If account exists, try to unlock it. if (account != null) { // See if account is locked out. if (account.IsAccountLockedOut()) { // Unlock account. account.UnlockAccount(); log.Info(unlockAccount + " has been unlocked at " + DateTime.Now.ToString()); Console.WriteLine(unlockAccount + " has been unlocked at " + DateTime.Now.ToString()); } else { log.Debug(unlockAccount + " was already unlocked at " + DateTime.Now.ToString()); Console.WriteLine(unlockAccount + " was already unlocked at " + DateTime.Now.ToString()); } // Dispose of account object. account.Dispose(); } } catch { } } log.Debug("Ending unlock cycle. Waiting for next cycle to begin."); // Sleep for specified time or signal is received. this.stopping.WaitOne(this.config.UnlockFrequency * 1000); } // Signal processing has ended. this.stoppedEvent.Set(); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="adId">Id of the ad to be updated.</param> public void Run(AdWordsUser user, long adId) { using (AdService adService = (AdService)user.GetService(AdWordsService.v201806.AdService)) { // Create an expanded text ad using the provided ad ID. ExpandedTextAd expandedTextAd = new ExpandedTextAd { id = adId, // Update some properties of the expanded text ad. headlinePart1 = "Cruise to Pluto #" + ExampleUtilities.GetShortRandomString(), headlinePart2 = "Tickets on sale now", description = "Best space cruise ever.", finalUrls = new string[] { "http://www.example.com/" }, finalMobileUrls = new string[] { "http://www.example.com/mobile" } }; // Create ad group ad operation and add it to the list. AdOperation operation = new AdOperation { operand = expandedTextAd, @operator = Operator.SET }; try { // Update the ad on the server. AdReturnValue result = adService.mutate(new AdOperation[] { operation }); ExpandedTextAd updatedAd = (ExpandedTextAd)result.value[0]; // Print out some information. Console.WriteLine("Expanded text ad with ID {0} was updated.", updatedAd.id); Console.WriteLine( "Headline part 1: {0}\nHeadline part 2: {1}\nDescription: {2}" + "\nFinal URL: {3}\nFinal mobile URL: {4}", updatedAd.headlinePart1, updatedAd.headlinePart2, updatedAd.description, updatedAd.finalUrls[0], updatedAd.finalMobileUrls[0]); } catch (Exception e) { throw new System.ApplicationException("Failed to update expanded text ad.", e); } } }
public ComputerSearchViewModel(AdService adService) { _adService = adService; _canSearch = _canSave = true; _nullErrorComputer = new Computer() { Name = "Null Error", DescPrefix = "None", Description = "" }; }
public async Task get_all_async_should_invoke_get_all_async_on_repository() { // Arrange var adService = new AdService(_adRepositoryMock.Object, _mapperMock.Object); // Act await adService.GetAllAsync(); // Assert _adRepositoryMock.Verify(x => x.GetAllAsync(), Times.Once); }
// // GET: /Adm/Material/List public ActionResult List() { var pageIndex = CECRequest.GetQueryInt("page", 1); var list = AdService.List(new AdSearchSetting() { PageIndex = pageIndex }); ViewBag.List = list; return(View()); }
private void Awake() { if (Instance == null) { GameObject.DontDestroyOnLoad(gameObject); Instance = this; } else { Destroy(gameObject); } }
public ApplicationViewModel() { DescriptionPrefix.Initialize(); LoadAppSettings(); var adService = new AdService(); PageViewModels.Add(new HomeViewModel(adService)); PageViewModels.Add(new ComputerViewModel(adService)); PageViewModels.Add(new PasswordViewModel(adService)); PageViewModels.Add(new ConfigurationViewModel(adService)); CurrentPageViewModel = PageViewModels[0]; }
public RootController(IMannsRepository repo, IMailService mailService, IMemoryCache memoryCache, ILogger <RootController> logger, AdService adService, IConfiguration config) { _repo = repo; _memoryCache = memoryCache; _config = config; _mailService = mailService; _logger = logger; _adService = adService; }
public void RepositoryContainsAds_ShouldReturnAds() { // arrange AdRepositoryMock.Setup(m => m.Get()).Returns(new List <Ad> { new Ad { Body = "meh" } }); var sut = new AdService(AdRepositoryMock.Object); // act var result = sut.Get(OrderAdBy.Time); // assert Assert.NotEmpty(result); }
protected void btnLoginSubmit_Click(object sender, EventArgs e) { _userName = txtUserName.Text; _password = txtPassword.Text; if (AdService.IsValidUser(_userName, _password, _domain)) { log.Info(_userName + " " + _password + " is authenticated"); Session["UserId"] = _userName; Response.Redirect("Default.aspx", true); } else { lblErrorMsg.Text = "Invalid User Please check UserName and Password"; log.Error(_userName + " " + _password + " is not correct"); } }
public void ModelNotNull_ShouldAddToRepository() { // arrange var sut = new AdService(AdRepositoryMock.Object); var model = new AddAdModel { Subject = "subject", Body = "body", EmailAddress = "email", PriceSek = 500 }; // act sut.Add(model); // assert AdRepositoryMock.Verify(m => m.Add(It.IsAny <Ad>())); }