public AndConstraint <BeatPulseContextAssertions> ContainsLiveness(string name, string because = "", params object [] becauseArgs) { Execute.Assertion .BecauseOf(because, becauseArgs) .ForCondition(!string.IsNullOrWhiteSpace(name)) .FailWith("You can't assert a liveness if you don't pass a proper name") .Then .Given(() => context.GetAllLiveness()) .ForCondition(liveness => liveness.Count(x => x.Name == name) == 1) .FailWith("Expected {context:liveness} to contains {0}{reason}, but found {1}", _ => name, liveness => liveness.Select(x => x.Name)); return(new AndConstraint <BeatPulseContextAssertions>(this)); }
public void register_multiple_liveness_with_the_same_name_and_path() { var context = new BeatPulseContext(); var options = new BeatPulseLivenessRegistrationOptions("name"); options.UsePath("path"); options.UseLiveness(new ActionLiveness((http, token) => Task.FromResult(("ok", true)))); context.AddLiveness(options.CreateRegistration()); options = new BeatPulseLivenessRegistrationOptions("name"); options.UsePath("path"); options.UseLiveness(new ActionLiveness((http, token) => Task.FromResult(("ok", true)))); context.AddLiveness(options.CreateRegistration()); context.GetAllLiveness("path") .Should() .HaveCount(2); }
public void register_multiple_liveness_with_the_sample_path() { var context = new BeatPulseContext(); var options = new BeatPulseLivenessRegistrationOptions("name1"); options.UsePath("path"); options.UseLiveness(new ActionLiveness((cancellationToken) => Task.FromResult(LivenessResult.Healthy()))); context.AddLiveness(options.CreateRegistration()); options = new BeatPulseLivenessRegistrationOptions("name2"); options.UsePath("path"); options.UseLiveness(new ActionLiveness((cancellationToken) => Task.FromResult(LivenessResult.Healthy()))); context.AddLiveness(options.CreateRegistration()); context.GetAllLiveness("path") .Should() .HaveCount(2); }