public void Execute() { // Arrange var profiles = new[] { new AwsProfile { Id = Guid.NewGuid() }, new AwsProfile { Id = Guid.NewGuid() } }; ProfileRepositoryMock.Setup(x => x.FindAll()).Returns(profiles); // Act RefreshEverything.Execute(); // Assert // This is good enough for now, but it isn't great because Execute calls an extension method on IBackgroundJobClient. // One can not verify that extension methods were called. BackgroundJobClientMock.Verify(x => x.Create( It.Is <Job>(j => j.Type == typeof(UpdateAllInstances)), It.IsAny <IState>()), Times.Exactly(profiles.Length)); BackgroundJobClientMock.Verify(x => x.Create( It.Is <Job>(j => j.Type == typeof(UpdateAllStacks)), It.IsAny <IState>()), Times.Exactly(profiles.Length)); }
public void ExitEarlyIfProfileMissing() { // Arrange ProfileRepositoryMock.Setup(x => x.Find(Profile.Id)).Returns((AwsProfile)null); // Act Command.Execute(Profile.Id, "HoojeyStack"); // Assert StackRepositoryMock.Verify(x => x.FindAll(), Times.Never); }