Exemplo n.º 1
0
        public void GetTreatmentWithConfig_WithoutBlockUntiltReady_ReturnsOff()
        {
            // Arrange.
            var client = new JSONFileClient($"{rootFilePath}splits_staging_3.json", "", _logMock.Object);

            // Act.
            var result = client.GetTreatmentWithConfig("key", "anding");

            // Assert.
            Assert.AreEqual("off", result.Treatment);
            Assert.IsNull(result.Config);
            _logMock.Verify(mock => mock.Error($"GetTreatment: the SDK is not ready, the operation cannot be executed."), Times.Never);
        }
Exemplo n.º 2
0
        public void GetTreatmentWithConfig_WhenNameDoesntExist_DontLogImpression()
        {
            // Arrange.
            var treatmentLogMock = new Mock <IListener <KeyImpression> >();
            var client           = new JSONFileClient("splits_staging_3.json", "", _logMock.Object, null, null, treatmentLogMock.Object);
            var splitName        = "not_exist";

            client.BlockUntilReady(1000);

            // Act.
            var result = client.GetTreatmentWithConfig("key", splitName);

            // Assert.
            Assert.AreEqual("control", result.Treatment);
            Assert.IsNull(result.Config);
            _logMock.Verify(mock => mock.Warn($"GetTreatment: you passed {splitName} 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());
        }