Beispiel #1
0
        public void Alt_Ctor_Should_Warm_ScriptService_When_ColdStartOnInit_Is_False()
        {
            // Arrange
            ScriptService.Setup(x => x.EvaluateAsync(string.Empty, null, null, default(CancellationToken))).Verifiable();

            // Act
            new AltQueryProcessor(new AltQueryOptions(), ScriptService.Object);

            // Assert
            ScriptService.Verify(x => x.EvaluateAsync(string.Empty, null, null, default(CancellationToken)), Times.Once);
        }
Beispiel #2
0
        public void Default_Ctor_Should_Warm_ScriptService_When_Called()
        {
            // Arrange
            ScriptService.Setup(x => x.AddReferences(Assembly.GetExecutingAssembly())).Verifiable();
            ScriptService.Setup(x => x.EvaluateAsync(string.Empty, null, null, default(CancellationToken))).Verifiable();

            // Act
            CreateSut();

            // Assert
            ScriptService.Verify(x => x.EvaluateAsync(string.Empty, null, null, default(CancellationToken)), Times.Once);
        }
Beispiel #3
0
        public void Default_Ctor_Should_Add_Calling_Assembly_When_Called()
        {
            // Arrange
            var assembly = Assembly.GetExecutingAssembly();

            ScriptService.Setup(x => x.AddReferences(assembly)).Verifiable();

            // Act
            var processor = CreateSut();

            // Assert
            processor.GetAltQueryOptions().Assemblies.Should().HaveCount(1);
            processor.GetAltQueryOptions().Assemblies.First().Should().BeSameAs(Assembly.GetExecutingAssembly());
            ScriptService.Verify(x => x.AddReferences(assembly), Times.Once);
        }
Beispiel #4
0
        public void Alt_Ctor_Should_Add_Calling_Assembly_When_GetCallingAssemblyOnInit_Is_True()
        {
            // Arrange
            var assembly = Assembly.GetExecutingAssembly();

            ScriptService.Setup(x => x.AddReferences(assembly)).Verifiable();

            // Act
            var processor = new AltQueryProcessor(new AltQueryOptions(), ScriptService.Object);

            // Assert
            processor.GetAltQueryOptions().Assemblies.Should().HaveCount(1);
            processor.GetAltQueryOptions().Assemblies.First().Should().BeSameAs(Assembly.GetExecutingAssembly());
            ScriptService.Verify(x => x.AddReferences(assembly), Times.Once);
        }
Beispiel #5
0
        public void Alt_Ctor_Should_Not_Warm_ScriptService_When_ColdStartOnInit_Is_True()
        {
            // Arrange
            var modifiedOptions = new AltQueryOptions()
            {
                ColdStartOnInit = true
            };

            ScriptService.Setup(x => x.EvaluateAsync(string.Empty, null, null, default(CancellationToken))).Verifiable();

            // Act
            new AltQueryProcessor(modifiedOptions, ScriptService.Object);

            // Assert
            ScriptService.Verify(x => x.EvaluateAsync(string.Empty, null, null, default(CancellationToken)), Times.Never);
        }
Beispiel #6
0
        public async Task ApplyAsync_Query_Should_Call_Script_EvaluateAsync_When_Invoked()
        {
            // Arrange
            var query = "MOCK-QUERY";

            ParserService.Setup(x => x.ToSearchModel(query));
            ScriptService.Setup(x =>
                                x.EvaluateAsync <Func <object, bool> >(It.IsAny <string>(), null, null, default(CancellationToken)))
            .ReturnsAsync(obj => obj != null);

            // Act
            var sut = CreateSut();
            await sut.ApplyAsync(query, new List <object>());

            // Assert
            ScriptService.Verify(x => x.EvaluateAsync <Func <object, bool> >(It.IsAny <string>(), null, null, default(CancellationToken)), Times.Once);
        }
Beispiel #7
0
        public void Alt_Ctor_Should_Not_Add_Assembly_When_GetCallingAssemblyOnInit_Is_False()
        {
            // Arrange
            var modifiedOptions = new AltQueryOptions()
            {
                GetCallingAssemblyOnInit = false
            };

            ScriptService.Setup(x => x.AddReferences(It.IsAny <Assembly>())).Verifiable();

            // Act
            var processor = new AltQueryProcessor(modifiedOptions, ScriptService.Object);

            // Assert
            processor.GetAltQueryOptions().Assemblies.Should().HaveCount(0);
            ScriptService.Verify(x => x.AddReferences(It.IsAny <Assembly>()), Times.Never);
        }
        public void AddReferences_Should_Call_AddReferences_On_ScriptService_When_Called()
        {
            // Arrange
            var options = new AltQueryOptions()
            {
                GetCallingAssemblyOnInit = false
            };
            var assemblies = new List <Assembly>()
            {
                Assembly.GetEntryAssembly()
            }.ToArray();

            ScriptService.Setup(x => x.AddReferences(assemblies)).Verifiable();

            // Act
            var sut = new AltQueryProcessor(options, ScriptService.Object);

            sut.AddReferences(assemblies);

            // Assert
            ScriptService.Verify(x => x.AddReferences(assemblies), Times.Once);
        }