public void Create() { var context = new Mock <IContextAware>(); var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var proposal = new DatasetActivationProposal { PercentageOfAvailableDisk = 5, PercentageOfMaximumMemory = 100, PercentageOfPhysicalMemory = 75, TransferTime = new TimeSpan(0, 0, 1, 0, 0), ActivationTime = new TimeSpan(0, 0, 0, 1, 0), }; var plan = CreateNewDistributionPlan( proposal, CreateOfflineInfo(new Mock <IPersistenceInformation>().Object), systemDiagnostics); var suggestion = new DistributionSuggestion(plan); var parameter = new MachineSelectorParameter( context.Object, new List <DistributionSuggestion> { suggestion, }); Assert.That( parameter.Suggestions, Is.EquivalentTo( new List <DistributionSuggestion> { suggestion, })); }
private static MachineSelectorParameter CreateInstance(int rating) { var context = new Mock <IContextAware>(); var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var proposal = new DatasetActivationProposal { PercentageOfAvailableDisk = 5 * rating, PercentageOfMaximumMemory = 75, PercentageOfPhysicalMemory = 90, TransferTime = new TimeSpan(0, 0, rating, 0, 0), ActivationTime = new TimeSpan(0, 0, 0, rating, 0), }; var plan = CreateNewDistributionPlan( proposal, CreateOfflineInfo(new Mock <IPersistenceInformation>().Object), systemDiagnostics); var suggestion = new DistributionSuggestion(plan); return(new MachineSelectorParameter( context.Object, new List <DistributionSuggestion> { suggestion, })); }
public void ConvertWithDistributionSuggestion() { var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var plan = CreateNewDistributionPlan( new DatasetActivationProposal(), CreateOfflineInfo(new Mock<IPersistenceInformation>().Object), systemDiagnostics); var model = new DistributionSuggestion(plan); var converter = new DistributionSuggestionToTextConverter(); var convertedValue = converter.Convert(model, null, null, null); Assert.AreEqual(plan.MachineToDistributeTo.ToString(), convertedValue); }
/// <summary> /// Initializes a new instance of the <see cref="DistributionSuggestionProxy"/> class. /// </summary> /// <param name="suggestion">The suggestion for which the current object is a proxy.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="suggestion"/> is <see langword="null" />. /// </exception> public DistributionSuggestionProxy(DistributionSuggestion suggestion) { { Lokad.Enforce.Argument(() => suggestion); } Rating = suggestion.Rating; MachineToDistributeTo = suggestion.Plan.MachineToDistributeTo; TransferTime = suggestion.Plan.Proposal.TransferTime; ActivationTime = suggestion.Plan.Proposal.ActivationTime; PercentageOfAvailableDisk = suggestion.Plan.Proposal.PercentageOfAvailableDisk; PercentageOfMaximumMemory = suggestion.Plan.Proposal.PercentageOfMaximumMemory; PercentageOfPhysicalMemory = suggestion.Plan.Proposal.PercentageOfPhysicalMemory; }
public void ConvertWithDistributionSuggestion() { var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var plan = CreateNewDistributionPlan( new DatasetActivationProposal(), CreateOfflineInfo(new Mock <IPersistenceInformation>().Object), systemDiagnostics); var model = new DistributionSuggestion(plan); var converter = new DistributionSuggestionToTextConverter(); var convertedValue = converter.Convert(model, null, null, null); Assert.AreEqual(plan.MachineToDistributeTo.ToString(), convertedValue); }
public void Initialize() { var context = new Mock <IContextAware>(); var view = new Mock <IMachineSelectorView>(); { view.SetupSet(v => v.Model = It.IsAny <MachineSelectorModel>()) .Verifiable(); } var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var plan = CreateNewDistributionPlan( new DatasetActivationProposal(), CreateOfflineInfo(new Mock <IPersistenceInformation>().Object), systemDiagnostics); var suggestion = new DistributionSuggestion(plan); var parameter = new MachineSelectorParameter( context.Object, new List <DistributionSuggestion> { suggestion, }); var container = new Mock <IDependencyInjectionProxy>(); { container.Setup(c => c.Resolve <IContextAware>()) .Returns(context.Object); } var presenter = new MachineSelectorPresenter(container.Object); ((IPresenter)presenter).Initialize(view.Object, parameter); Assert.AreSame(view.Object, presenter.View); Assert.AreSame(parameter, presenter.Parameter); view.VerifySet(v => v.Model = It.IsAny <MachineSelectorModel>(), Times.Once()); }
public void Initialize() { var context = new Mock<IContextAware>(); var view = new Mock<IMachineSelectorView>(); { view.SetupSet(v => v.Model = It.IsAny<MachineSelectorModel>()) .Verifiable(); } var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var plan = CreateNewDistributionPlan( new DatasetActivationProposal(), CreateOfflineInfo(new Mock<IPersistenceInformation>().Object), systemDiagnostics); var suggestion = new DistributionSuggestion(plan); var parameter = new MachineSelectorParameter( context.Object, new List<DistributionSuggestion> { suggestion, }); var container = new Mock<IDependencyInjectionProxy>(); { container.Setup(c => c.Resolve<IContextAware>()) .Returns(context.Object); } var presenter = new MachineSelectorPresenter(container.Object); ((IPresenter)presenter).Initialize(view.Object, parameter); Assert.AreSame(view.Object, presenter.View); Assert.AreSame(parameter, presenter.Parameter); view.VerifySet(v => v.Model = It.IsAny<MachineSelectorModel>(), Times.Once()); }
public void Create() { var context = new Mock<IContextAware>(); { context.Setup(c => c.IsSynchronized) .Returns(true); } var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var plan = CreateNewDistributionPlan( new DatasetActivationProposal(), CreateOfflineInfo(new Mock<IPersistenceInformation>().Object), systemDiagnostics); var suggestion = new DistributionSuggestion(plan); var model = new MachineSelectorModel( context.Object, new List<DistributionSuggestion> { suggestion, }, new CurrentThreadTaskScheduler()); Assert.IsNotNull(model.AvailableProposals); Assert.That( model.AvailableProposals, Is.EquivalentTo( new List<DistributionSuggestion> { suggestion, })); Assert.IsFalse(model.IsLoading); }
public void Create() { var context = new Mock <IContextAware>(); { context.Setup(c => c.IsSynchronized) .Returns(true); } var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var plan = CreateNewDistributionPlan( new DatasetActivationProposal(), CreateOfflineInfo(new Mock <IPersistenceInformation>().Object), systemDiagnostics); var suggestion = new DistributionSuggestion(plan); var model = new MachineSelectorModel( context.Object, new List <DistributionSuggestion> { suggestion, }, new CurrentThreadTaskScheduler()); Assert.IsNotNull(model.AvailableProposals); Assert.That( model.AvailableProposals, Is.EquivalentTo( new List <DistributionSuggestion> { suggestion, })); Assert.IsFalse(model.IsLoading); }