public void Correctly_creates_new_application_instance_if_existing_instance_does_not_exist() { ApplicationInstance instance = new ApplicationInstance(); MockRepository mocks = new MockRepository(); ISystemEnvironment environment = mocks.CreateMock <ISystemEnvironment>(); IConfigurationReader configurationReader = mocks.CreateMock <IConfigurationReader>(); IApplicationInstanceRepository repository = mocks.CreateMock <IApplicationInstanceRepository>(); IApplicationInstanceFactory factory = mocks.CreateMock <IApplicationInstanceFactory>(); using (mocks.Record()) { Expect.Call(environment.GetMachineName()).Return("MyMachine"); Expect.Call(configurationReader.GetRequiredSetting("TarantinoWebManagementHttpHost")).Return("www.myapp.com"); Expect.Call(repository.GetByMaintenanceHostHeaderAndMachineName("www.myapp.com", "MyMachine")).Return(null); Expect.Call(factory.Create()).Return(instance); repository.Save(instance); } using (mocks.Playback()) { ICurrentApplicationInstanceRetriever retriever = new CurrentApplicationInstanceRetriever(environment, configurationReader, repository, factory); Assert.That(retriever.GetApplicationInstance(), Is.SameAs(instance)); } mocks.VerifyAll(); }
public CurrentApplicationInstanceRetriever(ISystemEnvironment environment, IConfigurationReader configurationReader, IApplicationInstanceRepository repository, IApplicationInstanceFactory factory) { _environment = environment; _configurationReader = configurationReader; _repository = repository; _factory = factory; }
public CurrentApplicationInstanceRetriever(ISystemEnvironment environment, IConfigurationReader configurationReader, IApplicationInstanceRepository repository, IApplicationInstanceFactory factory) { _environment = environment; _configurationReader = configurationReader; _repository = repository; _factory = factory; }
public ApplicationListingBodyView(IAdministratorSecurityChecker securityChecker, IApplicationInstanceRepository applicationInstanceRepository, IResourceFileLocator fileLocator, ITokenReplacer replacer, IApplicationListingRowView applicationListingRowView) { this.checker = securityChecker; this.applicationInstanceRepository = applicationInstanceRepository; this.fileLocator = fileLocator; this.replacer = replacer; this.applicationListingRowView = applicationListingRowView; }
public ApplicationListingBodyView(IAdministratorSecurityChecker securityChecker, IApplicationInstanceRepository applicationInstanceRepository, IResourceFileLocator fileLocator, ITokenReplacer replacer, IApplicationListingRowView applicationListingRowView) { this.checker = securityChecker; this.applicationInstanceRepository = applicationInstanceRepository; this.fileLocator = fileLocator; this.replacer = replacer; this.applicationListingRowView = applicationListingRowView; }
public void Correctly_returns_html_for_page_for_an_administrator() { List <ApplicationInstance> applicationList = new List <ApplicationInstance>(); //application group 1 applicationList.Add(new ApplicationInstance()); applicationList[0].MaintenanceHostHeader = "1"; applicationList.Add(new ApplicationInstance()); applicationList[1].MaintenanceHostHeader = "1"; //application group 2 applicationList.Add(new ApplicationInstance()); applicationList[2].MaintenanceHostHeader = "2"; applicationList.Add(new ApplicationInstance()); applicationList[3].MaintenanceHostHeader = "2"; MockRepository mocks = new MockRepository(); IApplicationInstanceRepository repository = mocks.CreateMock <IApplicationInstanceRepository>(); IResourceFileLocator fileLocator = mocks.CreateMock <IResourceFileLocator>(); ITokenReplacer replacer = mocks.CreateMock <ITokenReplacer>(); IAdministratorSecurityChecker securityChecker = mocks.CreateMock <IAdministratorSecurityChecker>(); IApplicationListingRowView applicationListingRowView = mocks.CreateMock <IApplicationListingRowView>(); using (mocks.Record()) { Expect.Call(securityChecker.IsCurrentUserAdministrator()).Return(true); Expect.Call(repository.GetAll()).Return(applicationList); Expect.Call(fileLocator.ReadTextFile("Tarantino.Core", ApplicationListingBodyView.BodyTemplate)).Return("body template"); replacer.Text = "body template"; Expect.Call(applicationListingRowView.BuildFirstRowHtml(applicationList[0], 2)).Return("1"); Expect.Call(applicationListingRowView.BuildMRowHtml(applicationList[1])).Return("2"); Expect.Call(applicationListingRowView.BuildFirstRowHtml(applicationList[2], 2)).Return("3"); Expect.Call(applicationListingRowView.BuildMRowHtml(applicationList[3])).Return("4"); replacer.Replace("ROWS", "1234"); Expect.Call(replacer.Text).Return("formatted HTML"); } using (mocks.Playback()) { IApplicationListingBodyView view = new ApplicationListingBodyView(securityChecker, repository, fileLocator, replacer, applicationListingRowView); string html = view.BuildHtml(); Assert.That(html, Is.EqualTo("formatted HTML")); } mocks.VerifyAll(); }
protected override void OnProcessRequest() { if (_authenticated && _context.Request["id"] != null) { Guid id = new Guid(_context.Request["id"]); IApplicationInstanceRepository repository = ObjectFactory.GetInstance <IApplicationInstanceRepository>(); ApplicationInstance applicationInstance = repository.GetById(id); string hostName = _context.Request.Form.Get("hostname"); if (hostName != null) { applicationInstance.UniqueHostHeader = hostName; repository.Save(applicationInstance); } Write(ListApplications(applicationInstance)); } }
public void Correctly_disables_application_instance() { ApplicationInstance instance = new ApplicationInstance(); MockRepository mocks = new MockRepository(); IApplicationInstanceRepository repository = mocks.CreateMock <IApplicationInstanceRepository>(); IApplicationInstanceContext context = mocks.CreateMock <IApplicationInstanceContext>(); using (mocks.Record()) { Expect.Call(context.GetCurrent()).Return(instance); repository.Save(instance); } using (mocks.Playback()) { IAvailabilityStatusUpdater updater = new AvailabilityStatusUpdater(repository, context); updater.SetAvailabilityStatus(false); Assert.That(instance.AvailableForLoadBalancing, Is.False); } mocks.VerifyAll(); }
public AvailabilityStatusUpdater(IApplicationInstanceRepository repository, IApplicationInstanceContext context) { _repository = repository; _context = context; }
public AvailabilityStatusUpdater(IApplicationInstanceRepository repository, IApplicationInstanceContext context) { _repository = repository; _context = context; }