public void should_parse_fail_response() { var result = new DynamicDns(new FakeWebRequest(true)).Update("labs", "dundermifflin.com", "21k34h21g34g123h1g23134k43h1k23g4", "207.97.227.245"); result.IpAddress.ShouldBeEmpty(); result.Errors.Count().ShouldEqual(2); result.Errors.First().ShouldEqual("Domain name not found"); result.Errors.Skip(1).First().ShouldEqual("Invalid key"); }
static void Main(string[] args) { Console.WriteLine(); Console.WriteLine("CheapSkate {0} - NameCheap DDNS Client", Assembly.GetExecutingAssembly().GetName().Version); Console.WriteLine(); if (args.Length == 0) { var descriptions = OptionParser.GetOptions<Options>(); descriptions.ToList().ForEach(x => Console.WriteLine(" -{0}{1}", x.Key.PadRight(10), x.Value)); return; } Options options = null; try { options = OptionParser.Parse<Options>(args); } catch (MissingArgumentsException e) { Console.WriteLine(e.Message); Environment.Exit(1); } var filename = Assembly.GetEntryAssembly().GetName().Name; var consoleLogger = new ConsoleLogger(); var fileLogger = new FileLogger(filename + ".log"); var logger = string.IsNullOrEmpty(options.Email) ? new CompositeLogger(fileLogger, consoleLogger) : new CompositeLogger(fileLogger, consoleLogger, new EmailLogger(options.SmtpServer, "CheapSkate Alert", string.Format("cheapskate@{0}", options.Domain), options.Email)); var cache = new Cache(filename + ".cache"); var dynamicDns = new DynamicDns(new WebRequest()); Console.WriteLine("Connecting..."); if (!new Updater(logger, cache, dynamicDns).Update(options)) { Console.WriteLine("Operation completed with errors. :("); Environment.Exit(1); } Console.WriteLine("Operation completed successfully. :D"); }
public Updater(ILogger logger, ICache cache, DynamicDns dynamicDns) { _logger = logger; _cache = cache; _dynamicDns = dynamicDns; }
public void should_parse_success_response() { var result = new DynamicDns(new FakeWebRequest(false)).Update("labs", "dundermifflin.com", "21k34h21g34g123h1g23134k43h1k23g4", "207.97.227.245"); result.IpAddress.ShouldEqual("207.97.227.245"); result.Errors.ShouldBeEmpty(); }