public void CreatePublishedAssemblyTest()
        {
            // Arrange
            var mockLogManager          = new Mock <ILogManager>();
            var mockRuleSetRepository   = new Mock <IRuleSetRepository>();
            var mockRuleSetTranslator   = new Mock <IRuleSetTranslator>();
            var mockRuleAssemblyService = new Mock <IRuleSetAssemblyService>();
            var testRuleSet             = CreateTestRuleSet();

            mockRuleSetTranslator.Setup(x => x.Translate(It.IsAny <IRuleSet>(), true))
            .Returns(It.IsAny <string>());
            mockRuleAssemblyService.Setup(x => x.CreateAssembly(It.IsAny <IRuleSet>()))
            .Returns(It.IsAny <byte[]>());

            // Act
            var sut = new RuleApplicationService(
                mockLogManager.Object, mockRuleSetRepository.Object, mockRuleSetTranslator.Object, mockRuleAssemblyService.Object);

            var response = sut.CreateAssembly(testRuleSet, true);

            // Assert
            response.IsSuccessful.Should().BeTrue();
            response.Errors.Count.Should().Be(0);

            mockRuleSetTranslator.Verify(x => x.Translate(It.IsAny <IRuleSet>(), true));
            mockRuleAssemblyService.Verify(x => x.CreateAssembly(It.IsAny <IRuleSet>()));
        }
Esempio n. 2
0
        public void CreatePublishedAssemblyTest()
        {
            // Arrange
            var mockLogManager        = new Mock <ILogManager>();
            var mockRuleSetRepository = new Mock <IRuleSetRepository>();
            var mockRuleTerminalApplicationService = new Mock <IRuleGrammarTerminalApplicationService>();

            mockRuleTerminalApplicationService.Setup(x => x.GetAllAsync())
            .Returns(Task.FromResult(GetMockRuleTerminals()));

            var businessRuleParser =
                new BusinessRuleParser(mockLogManager.Object, mockRuleTerminalApplicationService.Object);

            var rulesetTranslator   = new RuleSetTranslator(businessRuleParser);
            var ruleAssemblyService = new RuleSetAssemblyService(mockLogManager.Object);


            var testRuleSet = CreateTestRuleSet();

            // Act
            var sut = new RuleApplicationService(
                mockLogManager.Object, mockRuleSetRepository.Object, rulesetTranslator, ruleAssemblyService);

            var response = sut.CreateAssembly(testRuleSet, true);

            // Assert
            response.IsSuccessful.Should().BeTrue();
            response.Errors.Count.Should().Be(0);
            response.Content.GeneratedAssembly.Length.Should().BeGreaterThan(0);
        }