Skip to content

Commit

Permalink
Update the namespace block for the cherry pick runner test fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbware committed Oct 18, 2023
1 parent d4d0c38 commit 242dcde
Showing 1 changed file with 32 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,46 @@
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace COMET.Web.Common.Tests.Utilities.CherryPick;

using NUnit.Framework;

using CDP4Common.SiteDirectoryData;
namespace COMET.Web.Common.Tests.Utilities.CherryPick
{
using NUnit.Framework;

using Moq;
using CDP4Common.SiteDirectoryData;

[TestFixture]
public class CherryPickRunnerTestFixture
{
private Common.Utilities.CherryPick.CherryPickRunner viewModel;
private Mock<Common.Services.SessionManagement.ISessionService> sessionService;
private Mock<Common.Utilities.CherryPick.INeedCherryPickedData> needCherryPickedData;
using Moq;

[SetUp]
public void Setup()
[TestFixture]
public class CherryPickRunnerTestFixture
{
this.sessionService = new Mock<Common.Services.SessionManagement.ISessionService>();
this.needCherryPickedData = new Mock<Common.Utilities.CherryPick.INeedCherryPickedData>();
this.viewModel = new Common.Utilities.CherryPick.CherryPickRunner(this.sessionService.Object);
}
private Common.Utilities.CherryPick.CherryPickRunner viewModel;
private Mock<Common.Services.SessionManagement.ISessionService> sessionService;
private Mock<Common.Utilities.CherryPick.INeedCherryPickedData> needCherryPickedData;

[Test]
public async Task VerifyProperties()
{
Assert.That(this.viewModel.IsCherryPicking, Is.False);
this.viewModel.InitializeProperties(new List<Common.Utilities.CherryPick.INeedCherryPickedData> { this.needCherryPickedData.Object });
[SetUp]
public void Setup()
{
this.sessionService = new Mock<Common.Services.SessionManagement.ISessionService>();
this.needCherryPickedData = new Mock<Common.Utilities.CherryPick.INeedCherryPickedData>();
this.viewModel = new Common.Utilities.CherryPick.CherryPickRunner(this.sessionService.Object);
}

[Test]
public async Task VerifyProperties()
{
Assert.That(this.viewModel.IsCherryPicking, Is.False);
this.viewModel.InitializeProperties(new List<Common.Utilities.CherryPick.INeedCherryPickedData> { this.needCherryPickedData.Object });

this.sessionService.Setup(x => x.Session.RetrieveSiteDirectory()).Returns(new SiteDirectory());
this.sessionService.Setup(x => x.Session.RetrieveSiteDirectory()).Returns(new SiteDirectory());

var propertyInfo = typeof(Common.Utilities.CherryPick.CherryPickRunner).GetProperty("IsCherryPicking", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
var propertyInfo = typeof(Common.Utilities.CherryPick.CherryPickRunner).GetProperty("IsCherryPicking", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);

propertyInfo?.SetValue(this.viewModel, true, null);
await this.viewModel.RunCherryPick();
this.needCherryPickedData.Verify(x => x.ProcessCherryPickedData(Moq.It.IsAny<IEnumerable<IEnumerable<CDP4Common.DTO.Thing>>>()), Times.Never);
propertyInfo?.SetValue(this.viewModel, true, null);
await this.viewModel.RunCherryPick();
this.needCherryPickedData.Verify(x => x.ProcessCherryPickedData(Moq.It.IsAny<IEnumerable<IEnumerable<CDP4Common.DTO.Thing>>>()), Times.Never);

propertyInfo?.SetValue(this.viewModel, false, null);
await this.viewModel.RunCherryPick();
this.needCherryPickedData.Verify(x => x.ProcessCherryPickedData(Moq.It.IsAny<IEnumerable<IEnumerable<CDP4Common.DTO.Thing>>>()), Times.Once);
propertyInfo?.SetValue(this.viewModel, false, null);
await this.viewModel.RunCherryPick();
this.needCherryPickedData.Verify(x => x.ProcessCherryPickedData(Moq.It.IsAny<IEnumerable<IEnumerable<CDP4Common.DTO.Thing>>>()), Times.Once);
}
}
}

0 comments on commit 242dcde

Please sign in to comment.