public void markTermDateForMissingEmployees_Test() { ContainerBuilder builder = new ContainerBuilder(); Mock <IUserCollectionDAL> ucDalMock = new Mock <IUserCollectionDAL>(); ucDalMock.Setup(u => u.GetActiveAdUsers()).Returns(new List <string> { "adUser1", "adUser2", "adUser3", "adUser4" }); builder.RegisterType <UserCollectionDAL>().As <IUserCollectionDAL>(); builder.RegisterInstance(ucDalMock.Object); IoC.Container = builder.Build(); ADProcessor adp = new ADProcessor(); Mock <IAuthorizeLogOn> adDalMock = new Mock <IAuthorizeLogOn>(); adDalMock.Setup(a => a.RetrieveUserInformation("adUser1", It.IsAny <string>())).Returns(new AuthorizeLogOnDTO { UserName = "******" }); adDalMock.Setup(a => a.RetrieveUserInformation("adUser2", It.IsAny <string>())).Returns((AuthorizeLogOnDTO)null); adDalMock.Setup(a => a.RetrieveUserInformation("adUser3", It.IsAny <string>())).Returns(new AuthorizeLogOnDTO { UserName = "******" }); adDalMock.Setup(a => a.RetrieveUserInformation("adUser4", It.IsAny <string>())).Returns((AuthorizeLogOnDTO)null); Mock <ICustomIdentityDAL> dbDalMock = new Mock <ICustomIdentityDAL>(); dbDalMock.Setup(d => d.SetTerminationDate("adUser2", It.IsAny <DateTime>())); dbDalMock.Setup(d => d.SetTerminationDate("adUser4", It.IsAny <DateTime>())); adp._markTermDateForMissingEmployees(adDalMock.Object, dbDalMock.Object); adDalMock.VerifyAll(); dbDalMock.VerifyAll(); }
public void insertUserInfoFromAD_Test() { ADProcessor adp = new ADProcessor(); Mock <IAuthorizeLogOn> adDalMock = new Mock <IAuthorizeLogOn>(); adDalMock.Setup(a => a.RetrieveUserInformation("emp1", It.IsAny <string>())).Returns(new AuthorizeLogOnDTO { UserName = "******" }); adDalMock.Setup(a => a.RetrieveUserInformation("emp2", It.IsAny <string>())).Returns((AuthorizeLogOnDTO)null); adDalMock.Setup(a => a.RetrieveUserInformation("emp3", It.IsAny <string>())).Returns(new AuthorizeLogOnDTO { UserName = "******" }); Mock <ICustomIdentityDAL> dbDalMock = new Mock <ICustomIdentityDAL>(); dbDalMock.Setup(d => d.SaveIdentity(It.IsAny <AuthorizeLogOnDTO>())); dbDalMock.Setup(d => d.SaveIdentity(It.IsAny <AuthorizeLogOnDTO>())); foreach (string s in new List <string> { "emp1", "emp2", "emp3" }) { adp._insertUserInfoFromAD(adDalMock.Object, dbDalMock.Object, s); } adDalMock.VerifyAll(); dbDalMock.VerifyAll(); }
public void insertEmployees_Test() { ADProcessor adp = new ADProcessor(); IEnumerable <string> employees = new List <string> { "emp1", "emp2", "emp3" }; Mock <IAuthorizeLogOn> adDalMock = new Mock <IAuthorizeLogOn>(); adDalMock.Setup(a => a.RetrieveUserInformation("emp1", It.IsAny <string>())).Returns(new AuthorizeLogOnDTO { UserName = "******" }); adDalMock.Setup(a => a.RetrieveUserInformation("emp2", It.IsAny <string>())).Returns((AuthorizeLogOnDTO)null); adDalMock.Setup(a => a.RetrieveUserInformation("emp3", It.IsAny <string>())).Returns(new AuthorizeLogOnDTO { UserName = "******" }); Mock <ICustomIdentityDAL> dbDalMock = new Mock <ICustomIdentityDAL>(); dbDalMock.Setup(d => d.SaveIdentity(It.IsAny <AuthorizeLogOnDTO>())); dbDalMock.Setup(d => d.SaveIdentity(It.IsAny <AuthorizeLogOnDTO>())); adp._insertEmployees(employees, adDalMock.Object, dbDalMock.Object); adDalMock.VerifyAll(); dbDalMock.VerifyAll(); }
public void adCycle_Harness() { AutofacBootstrapper.Init(); var adProcessor = new ADProcessor(); adProcessor.adCycle(); Assert.IsTrue(true); }
public static void Start(bool startAsConsole) { try { AutofacBootstrapper.Init(); var adProcessor = new ADProcessor(); if (startAsConsole) { adProcessor.Start(); } else { Task.Run(() => adProcessor.Start()); } } catch (Exception ex) { Logger.Fatal <Program>(ex.Message, ex); } }
public void saveManagerInformation_Test() { IList <string> employees = new List <string> { "emp1", "emp2", "emp3", "emp4", "emp5" }; Mock <IAuthorizeLogOn> adDalMock = new Mock <IAuthorizeLogOn>(); Mock <ICustomIdentityDAL> dbDalMock = new Mock <ICustomIdentityDAL>(); foreach (string employee in employees) { adDalMock.Setup(a => a.RetrieveUserInformation(employee, It.IsAny <string>())).Returns(new AuthorizeLogOnDTO { UserName = employee }); dbDalMock.Setup(d => d.SaveManagerInfo(It.IsAny <AuthorizeLogOnDTO>())); } ADProcessor._saveManagerInformation(employees, adDalMock.Object, dbDalMock.Object); adDalMock.VerifyAll(); dbDalMock.VerifyAll(); }