public void GetTreatmentsWithConfig_WhenNameDoesntExist_DontLogImpression() { // Arrange. var treatmentLogMock = new Mock <IListener <KeyImpression> >(); var client = new JSONFileClient("splits_staging_3.json", "", _logMock.Object, null, null, treatmentLogMock.Object); var splitNames = new List <string> { "not_exist", "not_exist_1" }; client.BlockUntilReady(1000); // Act. var result = client.GetTreatmentsWithConfig("key", splitNames); // Assert. foreach (var res in result) { Assert.AreEqual("control", res.Value.Treatment); Assert.IsNull(res.Value.Config); _logMock.Verify(mock => mock.Warn($"GetTreatment: you passed {res.Key} that does not exist in this environment, please double check what Splits exist in the web console."), Times.Once()); } treatmentLogMock.Verify(x => x.Log(It.IsAny <KeyImpression>()), Times.Never()); }
public void GetTreatmentsWithConfig_WithoutBlockUntiltReady_ReturnsEmptyList() { // Arrange. var client = new JSONFileClient($"{rootFilePath}splits_staging_3.json", "", _logMock.Object); // Act. var result = client.GetTreatmentsWithConfig("anding", new List <string>()); // Assert. Assert.IsTrue(result.Count == 0); _logMock.Verify(mock => mock.Error($"GetTreatment: the SDK is not ready, the operation cannot be executed."), Times.Never); }
public void GetTreatmentsWithConfig_WithoutBlockUntiltReady_ReturnsEmptyList() { // Arrange. var treatmentLogMock = new Mock <IListener <KeyImpression> >(); var client = new JSONFileClient("splits_staging_3.json", "", _logMock.Object, null, null, treatmentLogMock.Object); // Act. var result = client.GetTreatmentsWithConfig("key", new List <string>()); // Assert. Assert.IsTrue(result.Count == 0); _logMock.Verify(mock => mock.Error($"GetTreatmentsWithConfig: the SDK is not ready, the operation cannot be executed."), Times.Never()); }
public void GetTreatmentsWithConfig_WhenClientIsReadyAndFeaturesIsEmpty_ReturnsEmptyList() { // Arrange. var client = new JSONFileClient($"{rootFilePath}splits_staging_3.json", "", _logMock.Object); client.BlockUntilReady(100); // Act. var result = client.GetTreatmentsWithConfig("key", new List <string>()); // Assert. Assert.IsTrue(result.Count == 0); }
public void GetTreatmentsWithConfig_WhenClientIsReadyAndFeaturesIsEmpty_ReturnsEmptyList() { // Arrange. var treatmentLogMock = new Mock <IListener <KeyImpression> >(); var client = new JSONFileClient("splits_staging_3.json", "", _logMock.Object, null, null, treatmentLogMock.Object); client.BlockUntilReady(100); // Act. var result = client.GetTreatmentsWithConfig("key", new List <string>()); // Assert. Assert.IsTrue(result.Count == 0); }
public void GetTreatmentsWithConfig_WithoutBlockUntiltReady_ReturnsTreatments() { // Arrange. var client = new JSONFileClient($"{rootFilePath}splits_staging_3.json", "", _logMock.Object); // Act. var result = client.GetTreatmentsWithConfig("key", new List <string> { "anding", "whitelisting_elements" }); // Assert. var treatment1 = result.FirstOrDefault(r => r.Key.Equals("anding")); Assert.AreEqual("off", treatment1.Value.Treatment); Assert.IsNull(treatment1.Value.Config); var treatment2 = result.FirstOrDefault(r => r.Key.Equals("whitelisting_elements")); Assert.AreEqual("off", treatment2.Value.Treatment); Assert.IsNull(treatment2.Value.Config); _logMock.Verify(mock => mock.Error($"GetTreatment: the SDK is not ready, the operation cannot be executed."), Times.Never); }