public void Get_AddressOrDomainTest() { InitAddressRecords(); string addressType = "SMTP"; DomainManager dMgr = new DomainManager(CreateConfigStore()); Domain domain = new Domain("address1.domain1.com"); domain.Status = EntityStatus.New; dMgr.Add(domain); domain = new Domain("address2.domain2.com"); domain.Status = EntityStatus.Enabled; dMgr.Add(domain); AddressManager mgr = CreateManager(); string[] emailAddresses = new[] { "*****@*****.**", "*****@*****.**" }; IEnumerable <Address> actual = mgr.Get(emailAddresses, EntityStatus.New); Assert.Equal(0, actual.Count()); // // Now search with domainSearchEnabled = true // actual = mgr.Get(emailAddresses, true, EntityStatus.Enabled); Assert.Equal(0, actual.Count()); actual = mgr.Get(emailAddresses, true, EntityStatus.New); Assert.Equal(emailAddresses.Length, actual.Count()); for (int t = 0; t < actual.Count(); t++) { Assert.True(emailAddresses.Contains(actual.ToArray()[t].EmailAddress)); Assert.Equal(EntityStatus.New, actual.ToArray()[t].Status); Assert.Equal(addressType, actual.ToArray()[t].Type); } emailAddresses = new[] { "*****@*****.**", "*****@*****.**" }; actual = mgr.Get(emailAddresses, true, EntityStatus.Enabled); Assert.Equal(emailAddresses.Length, actual.Count()); // // domainSearchEnabled and no status. // actual = mgr.Get(emailAddresses, true); Assert.Equal(emailAddresses.Length, actual.Count()); for (int t = 0; t < actual.Count(); t++) { Assert.True(emailAddresses.Contains(actual.ToArray()[t].EmailAddress)); Assert.Equal(EntityStatus.Enabled, actual.ToArray()[t].Status); Assert.Equal(addressType, actual.ToArray()[t].Type); } }
public void AddTest2() { DomainManager target = CreateManager(); target.RemoveAll(); Assert.Equal(0, target.Count()); string name = BuildDomainName(GetRndDomainID()); target.Add(name); Assert.NotNull(target.Get(name)); }
public void AddTest3() { using (ConfigDatabase db = CreateConfigDatabase()) { DomainManager target = CreateManager(); target.RemoveAll(); Assert.Equal(0, target.Count()); string name = BuildDomainName(GetRndDomainID()); target.Add(db, name); db.SubmitChanges(); Assert.NotNull(target.Get(name)); } }
/// <summary> /// This method will clean, load and verify Domain records in the DB for testing purposes /// </summary> /// <param name="mgr">DomainManager instance used for controlling the Domain records</param> /// <param name="db">ConfigDatabase instance used as the target storage mechanism for the records</param> /// <remarks> /// this approach goes out to db each time it is called, however it ensures that clean records /// are present for every test that is execute, if it is taking too long, simply cut down on the /// number of items using the consts above /// </remarks> protected void InitDomainRecords(DomainManager mgr , ConfigDatabase db) { //---------------------------------------------------------------------------------------------------- //---clean all existing records mgr.RemoveAll(); foreach (string val in TestDomainNames) { mgr.Add(db, new Domain(val)); } //---------------------------------------------------------------------------------------------------- //---submit changes to db and verify existence of records db.SubmitChanges(); foreach (string val in TestDomainNames) { Assert.NotNull(mgr.Get(val)); } }
public void Get_AddressAndDomainTest() { InitAddressRecords(); string addressType = "SMTP"; DomainManager dMgr = new DomainManager(CreateConfigStore()); Domain domain = new Domain("address1.domain1.com"); domain.Status = EntityStatus.New; dMgr.Add(domain); // // [email protected] aready exists // AddressManager mgr = CreateManager(); string[] emailAddresses = new[] { "*****@*****.**", "*****@*****.**", "*****@*****.**" }; IEnumerable <Address> actual = mgr.Get(emailAddresses, EntityStatus.New); Assert.Equal(1, actual.Count()); // // Now search with domainSearchEnabled = true // actual = mgr.Get(emailAddresses, true, EntityStatus.Enabled); Assert.Equal(0, actual.Count()); actual = mgr.Get(emailAddresses, true, EntityStatus.New); Assert.Equal(emailAddresses.Length, actual.Count()); for (int t = 0; t < actual.Count(); t++) { Assert.True(emailAddresses.Any(e => e.Equals(actual.ToArray()[t].EmailAddress, StringComparison.OrdinalIgnoreCase))); Assert.Equal(EntityStatus.New, actual.ToArray()[t].Status); Assert.Equal(addressType, actual.ToArray()[t].Type); } }
public void Get_RoutedAddress() { InitAddressRecords(); DomainManager dMgr = new DomainManager(CreateConfigStore()); Domain domain = new Domain("address1.domain1.com"); domain.Status = EntityStatus.Enabled; dMgr.Add(domain); string addressType = "Undeliverable"; AddressManager aMgr = new AddressManager(CreateConfigStore()); MailAddress address = new MailAddress("*****@*****.**"); aMgr.Add(address, EntityStatus.Enabled, addressType); // // [email protected] aready exists // AddressManager mgr = CreateManager(); string[] emailAddresses = new[] { "*****@*****.**" }; IEnumerable <Address> actual = mgr.Get(emailAddresses, true, EntityStatus.Enabled); Assert.Equal(1, actual.Count()); for (int t = 0; t < actual.Count(); t++) { Assert.True(emailAddresses.Any(e => e.Equals(actual.ToArray()[t].EmailAddress, StringComparison.OrdinalIgnoreCase))); Assert.Equal(EntityStatus.Enabled, actual.ToArray()[t].Status); Assert.Equal(addressType, actual.ToArray()[t].Type); } actual = mgr.Get(emailAddresses, EntityStatus.Enabled); Assert.Equal(1, actual.Count()); for (int t = 0; t < actual.Count(); t++) { Assert.True(emailAddresses.Any(e => e.Equals(actual.ToArray()[t].EmailAddress, StringComparison.OrdinalIgnoreCase))); Assert.Equal(EntityStatus.Enabled, actual.ToArray()[t].Status); Assert.Equal(addressType, actual.ToArray()[t].Type); } actual = mgr.Get(emailAddresses, true); Assert.Equal(1, actual.Count()); for (int t = 0; t < actual.Count(); t++) { Assert.True(emailAddresses.Any(e => e.Equals(actual.ToArray()[t].EmailAddress, StringComparison.OrdinalIgnoreCase))); Assert.Equal(EntityStatus.Enabled, actual.ToArray()[t].Status); Assert.Equal(addressType, actual.ToArray()[t].Type); } actual = mgr.Get(emailAddresses); Assert.Equal(1, actual.Count()); for (int t = 0; t < actual.Count(); t++) { Assert.True(emailAddresses.Any(e => e.Equals(actual.ToArray()[t].EmailAddress, StringComparison.OrdinalIgnoreCase))); Assert.Equal(EntityStatus.Enabled, actual.ToArray()[t].Status); Assert.Equal(addressType, actual.ToArray()[t].Type); } }
public void Get_RoutedAddress() { InitAddressRecords(); DomainManager dMgr = new DomainManager(CreateConfigStore()); Domain domain = new Domain("address1.domain1.com"); domain.Status = EntityStatus.Enabled; dMgr.Add(domain); string addressType = "Undeliverable"; AddressManager aMgr = new AddressManager(CreateConfigStore()); MailAddress address = new MailAddress("*****@*****.**"); aMgr.Add(address, EntityStatus.Enabled, addressType); // // [email protected] aready exists // AddressManager mgr = CreateManager(); string[] emailAddresses = new[] { "*****@*****.**" }; IEnumerable<Address> actual = mgr.Get(emailAddresses, true, EntityStatus.Enabled); Assert.Equal(1, actual.Count()); for (int t = 0; t < actual.Count(); t++) { Assert.True(emailAddresses.Any(e => e.Equals(actual.ToArray()[t].EmailAddress, StringComparison.OrdinalIgnoreCase))); Assert.Equal(EntityStatus.Enabled, actual.ToArray()[t].Status); Assert.Equal(addressType, actual.ToArray()[t].Type); } actual = mgr.Get(emailAddresses, EntityStatus.Enabled); Assert.Equal(1, actual.Count()); for (int t = 0; t < actual.Count(); t++) { Assert.True(emailAddresses.Any(e => e.Equals(actual.ToArray()[t].EmailAddress, StringComparison.OrdinalIgnoreCase))); Assert.Equal(EntityStatus.Enabled, actual.ToArray()[t].Status); Assert.Equal(addressType, actual.ToArray()[t].Type); } actual = mgr.Get(emailAddresses, true); Assert.Equal(1, actual.Count()); for (int t = 0; t < actual.Count(); t++) { Assert.True(emailAddresses.Any(e => e.Equals(actual.ToArray()[t].EmailAddress, StringComparison.OrdinalIgnoreCase))); Assert.Equal(EntityStatus.Enabled, actual.ToArray()[t].Status); Assert.Equal(addressType, actual.ToArray()[t].Type); } actual = mgr.Get(emailAddresses); Assert.Equal(1, actual.Count()); for (int t = 0; t < actual.Count(); t++) { Assert.True(emailAddresses.Any(e => e.Equals(actual.ToArray()[t].EmailAddress, StringComparison.OrdinalIgnoreCase))); Assert.Equal(EntityStatus.Enabled, actual.ToArray()[t].Status); Assert.Equal(addressType, actual.ToArray()[t].Type); } }
public void Get_AddressAndDomainTest() { InitAddressRecords(); string addressType = "SMTP"; DomainManager dMgr = new DomainManager(CreateConfigStore()); Domain domain = new Domain("address1.domain1.com"); domain.Status = EntityStatus.New; dMgr.Add(domain); // // [email protected] aready exists // AddressManager mgr = CreateManager(); string[] emailAddresses = new[] { "*****@*****.**", "*****@*****.**", "*****@*****.**" }; IEnumerable<Address> actual = mgr.Get(emailAddresses, EntityStatus.New); Assert.Equal(1, actual.Count()); // // Now search with domainSearchEnabled = true // actual = mgr.Get(emailAddresses, true, EntityStatus.Enabled); Assert.Equal(0, actual.Count()); actual = mgr.Get(emailAddresses, true, EntityStatus.New); Assert.Equal(emailAddresses.Length, actual.Count()); for (int t = 0; t < actual.Count(); t++) { Assert.True(emailAddresses.Any(e => e.Equals(actual.ToArray()[t].EmailAddress, StringComparison.OrdinalIgnoreCase))); Assert.Equal(EntityStatus.New, actual.ToArray()[t].Status); Assert.Equal(addressType, actual.ToArray()[t].Type); } }
public void Get_AddressOrDomainTest() { InitAddressRecords(); string addressType = "SMTP"; DomainManager dMgr = new DomainManager(CreateConfigStore()); Domain domain = new Domain("address1.domain1.com"); domain.Status = EntityStatus.New; dMgr.Add(domain); domain = new Domain("address2.domain2.com"); domain.Status = EntityStatus.Enabled; dMgr.Add(domain); AddressManager mgr = CreateManager(); string[] emailAddresses = new[] { "*****@*****.**", "*****@*****.**" }; IEnumerable<Address> actual = mgr.Get(emailAddresses, EntityStatus.New); Assert.Equal(0, actual.Count()); // // Now search with domainSearchEnabled = true // actual = mgr.Get(emailAddresses, true, EntityStatus.Enabled); Assert.Equal(0, actual.Count()); actual = mgr.Get(emailAddresses, true, EntityStatus.New); Assert.Equal(emailAddresses.Length, actual.Count()); for (int t = 0; t < actual.Count(); t++) { Assert.True(emailAddresses.Contains(actual.ToArray()[t].EmailAddress)); Assert.Equal(EntityStatus.New, actual.ToArray()[t].Status); Assert.Equal(addressType, actual.ToArray()[t].Type); } emailAddresses = new[] { "*****@*****.**", "*****@*****.**" }; actual = mgr.Get(emailAddresses, true, EntityStatus.Enabled); Assert.Equal(emailAddresses.Length, actual.Count()); // // domainSearchEnabled and no status. // actual = mgr.Get(emailAddresses, true); Assert.Equal(emailAddresses.Length, actual.Count()); for (int t = 0; t < actual.Count(); t++) { Assert.True(emailAddresses.Contains(actual.ToArray()[t].EmailAddress)); Assert.Equal(EntityStatus.Enabled, actual.ToArray()[t].Status); Assert.Equal(addressType, actual.ToArray()[t].Type); } }