コード例 #1
0
 public void Should_throw_UnknownDataClientException()
 {
     Job job = new WmiClient();
     assemblyResolver.Expect(x => x.ResolveType(job)).Return(null);
     var ex = Assert.Throws<UnknownDataClientException>(() => this.dataClientFactory.Create(job));
     Assert.That(ex.Message, Is.EqualTo(string.Format("{0}", job.GetType().FullName)));
     assemblyResolver.VerifyAllExpectations();
 }
コード例 #2
0
 public void Should_Resolve_type_sucessfuly()
 {
     var job = new WmiClient();
     var files = new List<string>() { string.Format(@"{0}\SqlToGraphite.Plugin.Wmi.dll", Directory.GetCurrentDirectory()) };
     dir.Expect(x => x.GetFilesInCurrentDirectory(AssemblyResolver.FilesToScan)).Return(files);
     //Test
     assemblyResolver = new AssemblyResolver(this.dir, log);
     var rtn = assemblyResolver.ResolveType(job);
     //Assert
     Assert.That(rtn.FullName, Is.EqualTo(job.GetType().FullName));
     dir.VerifyAllExpectations();
 }
コード例 #3
0
 public void Should_ignore_bad_image_exception_for_not_dot_net_dlls()
 {
     File.WriteAllText("bad.dll", "abc");
     var job = new WmiClient() { Type = "SqlToGraphite.Plugin.Wmi.WmiClient" };
     var files = new List<string>() { string.Format(@"{0}\bad.dll", Directory.GetCurrentDirectory()), string.Format(@"{0}\SqlToGraphite.Plugin.Wmi.dll", Directory.GetCurrentDirectory()) };
     dir.Expect(x => x.GetFilesInCurrentDirectory(AssemblyResolver.FilesToScan)).Return(files);
     //Test
     assemblyResolver = new AssemblyResolver(this.dir, log);
     //Test
     var type = assemblyResolver.ResolveType(job);
     //Assert
     Assert.That(type.FullName, Is.EqualTo(job.GetType().FullName));
     File.Delete("bad.dll");
 }
コード例 #4
0
 public void Should_create_wmi_client()
 {
     var job = new WmiClient { Sql = "someSql", Name = "someName", Username = "******", Password = "******", Hostname = "hostname" };
     assemblyResolver.Expect(x => x.ResolveType(job)).Return(job.GetType());
     //Test
     var o = (WmiClient)this.dataClientFactory.Create(job);
     //Assert
     Assert.That(o.Sql, Is.EqualTo(job.Sql));
     Assert.That(o.Name, Is.EqualTo(job.Name));
     Assert.That(o.Path, Is.EqualTo(job.Path));
     Assert.That(o.Username, Is.EqualTo(job.Username));
     Assert.That(o.Password, Is.EqualTo(job.Password));
     Assert.That(o.Hostname, Is.EqualTo(job.Hostname));
     Assert.That(o, Is.Not.Null);
     Assert.That(o, Is.TypeOf<WmiClient>());
     assemblyResolver.VerifyAllExpectations();
 }