/// <summary> /// Build and write standard telemetry items to <see cref="Its.Log" />. /// </summary> protected static void WriteStandardTelemetry() { /*---------------------------------------------------------------------------* * Write telemetry: Log telemetry general records * *---------------------------------------------------------------------------*/ var dateTimeOfSampleInUtc = DateTime.UtcNow; var machineDetails = DomainFactory.CreateMachineDetails(); var processDetails = DomainFactory.CreateProcessDetails(); var processDirectory = Path.GetDirectoryName(processDetails.FilePath) ?? throw new InvalidOperationException("Could not get directory from process file path: " + processDetails.FilePath); var processSiblingAssemblies = Directory.GetFiles(processDirectory, "*", SearchOption.AllDirectories) .Where(_ => _.ToLowerInvariant().EndsWith(".exe") || _.ToLowerInvariant().EndsWith(".dll")).Select(_ => { try { return(AssemblyDetails.CreateFromFile(_)); } catch (Exception) { return(new AssemblyDetails(Path.ChangeExtension(Path.GetFileName(_), string.Empty), Version.Parse("1.0.0.0").ToString(), _, "UNKNOWN")); } }) .ToList(); var diagnosticsTelemetry = new DiagnosticsTelemetry(dateTimeOfSampleInUtc, machineDetails, processDetails, processSiblingAssemblies); Its.Log.Instrumentation.Log.Write(() => diagnosticsTelemetry); }
public void setUp() { FOLDomain domain = DomainFactory.crusadesDomain(); lexer = new FOLLexer(domain); parser = new FOLParser(lexer); }
public void Initialize() { this.logger = new Mock <ILogger>(); this.dependencyContainer = new Mock <IDependencyContainer>(); this.dependencyContainer.Setup(dc => dc.Resolve <ILogger>()).Returns(this.logger.Object); this.domainFactory = new DomainFactory(this.dependencyContainer.Object); }
public async Task DeveAutenticarUmUsuario() { var usuario = DomainFactory.BuildUsuario(); var autheticated = await _usuarioService.Authenticate(usuario); Assert.NotNull(autheticated); }
public void setUp() { StandardizeApartIndexicalFactory.flush(); weaponsKB = new FOLKnowledgeBase(DomainFactory.weaponsDomain()); kingsKB = new FOLKnowledgeBase(DomainFactory.kingsDomain()); }
public AllDomainTypesSpec() { var recorder = new Mock <IRecorder>(); var dependencyContainer = new Mock <IDependencyContainer>(); dependencyContainer.Setup(dc => dc.Resolve <IRecorder>()).Returns(recorder.Object); this.domainFactory = new DomainFactory(dependencyContainer.Object); }
public void MyTestMethod() { RepositoryConfiguration.GetConnection = delegate() { return(new SqlConnection()); }; RepositoryFactory.Mapper.LoadMapping(); DomainFactory.Mapper.LoadMapping(); var t = RepositoryFactory.GetInstance <IRepoTest>(); var t2 = DomainFactory.GetInstance <IRepoTest2>(); }
public void GivenMultipleDomains_TestOutputSet() { IDomain d1 = DomainFactory.CreateDomain(new int[] { 1, 2, 3 }); IDomain d2 = DomainFactory.CreateDomain(new string[] { "a", "b" }); IDomain d3 = DomainFactory.CreateDomain(new IDomain[] { d1, d2 }); IFuzzySet f1 = FuzzySetFactory.CreateFuzzySet(d1, new double[] { 1, 0.5, 0 }); IFuzzySet f2 = f1.CylindricalExtension(d3); }
public static void TestCreate() { // Arrange & Act var details = DomainFactory.CreateProcessDetails(); // Assert details.Should().NotBeNull(); }
public CSharpFizzBuzz.Application Create(IInput input, IOutput output) { var domainFactory = new DomainFactory(); var domainWorkflowFactory = new DomainWorkflowFactory(domainFactory); var domainWorkflowExceptionHandler = new DomainWorkflowExceptionHandler(); return(new CSharpFizzBuzz.Application(domainWorkflowFactory, domainWorkflowExceptionHandler, input, output)); }
public async Task DeveInserirUmCliente() { var cliente = DomainFactory.BuildCliente(); await _clienteService.Save(cliente); var result = await _unitOfWork.Commit(); Assert.NotEqual(0, result); }
public async Task DeveInserirUmLivro() { var livro = DomainFactory.BuildLivro(); await _livroService.Save(livro); var result = await _unitOfWork.Commit(); Assert.Equal(1, result); }
public async Task DeveInserirUmUsuario() { var usuario = DomainFactory.BuildUsuario(); var account = await _usuarioService.Register(usuario); //await _unitOfWork.GetRepository<Usuario>().Save(usuario); //var result = await _unitOfWork.Commit(); //Assert.NotEqual(0, result); }
public static FOLKnowledgeBase createKingsKnowledgeBase(InferenceProcedure infp) { FOLKnowledgeBase kb = new FOLKnowledgeBase(DomainFactory.kingsDomain(), infp); kb.tell("((King(x) AND Greedy(x)) => Evil(x))"); kb.tell("King(John)"); kb.tell("King(Richard)"); kb.tell("Greedy(John)"); return(kb); }
public static FOLKnowledgeBase CreateRingOfThievesKnowledgeBase( IInferenceProcedure infp) { var kb = new FOLKnowledgeBase(DomainFactory.RingOfThievesDomain(), infp); // s(x) => ~c(x) One who skis never gets caught kb.tell("(Skis(x) => NOT(Caught(x)))"); // c(x) => ~s(x) Those who are caught don't ever ski kb.tell("(Caught(x) => NOT(Skis(x)))"); // p(x,y) & c(y) => s(x) Jailbird parents have skiing kids kb.tell("((Parent(x,y) AND Caught(y)) => Skis(x))"); // s(x) & f(x,y) => s(y) All friends ski together kb.tell("(Skis(x) AND Friend(x,y) => Skis(y))"); // f(x,y) => f(y,x) Friendship is symmetric kb.tell("(Friend(x,y) => Friend(y,x))"); // FACTS // 1. { p(Mike,Joe) } Premise kb.tell("Parent(Mike, Joe)"); // 2. { p(Janet,Joe) } Premise kb.tell("Parent(Janet,Joe)"); // 3. { p(Nancy,Mike) } Premise kb.tell("Parent(Nancy,Mike)"); // 4. { p(Ernie,Janet) } Premise kb.tell("Parent(Ernie,Janet)"); // 5. { p(Bert,Nancy) } Premise kb.tell("Parent(Bert,Nancy)"); // 6. { p(Red,Ernie) } Premise kb.tell("Parent(Red,Ernie)"); // 7. { f(Red,Bert) } Premise kb.tell("Friend(Red,Bert)"); // 8. { f(Drew,Nancy) } Premise kb.tell("Friend(Drew,Nancy)"); // 9. { c(Mike) } Premise kb.tell("Caught(Mike)"); // 10. { c(Ernie) } Premise kb.tell("Caught(Ernie)"); return(kb); }
public async Task DeveInserirUmaInstituicaoEnsino() { var instituicaoEnsino = DomainFactory.BuildIntituicao(); await _instituicaoEnsinoService.Save(instituicaoEnsino); await _unitOfWork.Commit(); var instituicaoEnsinoAdd = await _instituicaoEnsinoService.FindInstituicaoByName(instituicaoEnsino.Pessoa.Nome, new PaginacaoParametroDto()); Assert.NotNull(instituicaoEnsinoAdd); }
public static FOLKnowledgeBase createLovesAnimalKnowledgeBase(InferenceProcedure infp) { FOLKnowledgeBase kb = new FOLKnowledgeBase(DomainFactory.lovesAnimalDomain(), infp); kb.tell("FORALL x (FORALL y (Animal(y) => Loves(x, y)) => EXISTS y Loves(y, x))"); kb.tell("FORALL x (EXISTS y (Animal(y) AND Kills(x, y)) => FORALL z NOT(Loves(z, x)))"); kb.tell("FORALL x (Animal(x) => Loves(Jack, x))"); kb.tell("(Kills(Jack, Tuna) OR Kills(Curiosity, Tuna))"); kb.tell("Cat(Tuna)"); kb.tell("FORALL x (Cat(x) => Animal(x))"); return(kb); }
public void Initialize() { this.logger = new Mock <ILogger>(); this.identifierFactory = new Mock <IIdentifierFactory>(); this.identifierFactory.Setup(f => f.Create(It.IsAny <IIdentifiableEntity>())) .Returns("anid".ToIdentifier); this.dependencyContainer = new Mock <IDependencyContainer>(); this.dependencyContainer.Setup(dc => dc.Resolve <ILogger>()) .Returns(this.logger.Object); this.dependencyContainer.Setup(dc => dc.Resolve <IIdentifierFactory>()) .Returns(this.identifierFactory.Object); this.factory = new DomainFactory(this.dependencyContainer.Object); }
public void ProcessCommandToEvent() { var location = "Mayfair"; var command = CommandFactory.Default.CreateCommand("command1", location, new CreateLocation(location)); var commandEngine = DomainFactory.CreateCommandEngine(this.boundedContextModel, eventStore.Object); var events = commandEngine.Process(command); Assert.IsNotNull(@events.SingleOrDefault(e => e.EventBody is LocationCreated)); this.eventStore.Verify(x => x.Store(location, events)); }
public static FOLKnowledgeBase createWeaponsKnowledgeBase(InferenceProcedure infp) { FOLKnowledgeBase kb = new FOLKnowledgeBase(DomainFactory.weaponsDomain(), infp); kb.tell("( (((American(x) AND Weapon(y)) AND Sells(x,y,z)) AND Hostile(z)) => Criminal(x))"); kb.tell(" Owns(Nono, M1)"); kb.tell(" Missile(M1)"); kb.tell("((Missile(x) AND Owns(Nono,x)) => Sells(West,x,Nono))"); kb.tell("(Missile(x) => Weapon(x))"); kb.tell("(Enemy(x,America) => Hostile(x))"); kb.tell("American(West)"); kb.tell("Enemy(Nono,America)"); return(kb); }
public void ProcessTwoSequentialCommandsTest() { var eventStore = new InMemoryEventStore(); var contextModel = new BoundedContextModel().WithAssemblyContaining <Location>(); var engine = DomainFactory.CreateDomainExecutionEngine(contextModel, eventStore, DomainOptions.Defaults); var item = new StockItem("item", "123"); var results1 = engine.Process(CommandFactory.Default.CreateCommand <CreateLocation>("c1", "c1", "ar1", new CreateLocation("locationA"))); var results2 = engine.Process(CommandFactory.Default.CreateCommand <AdjustIn>("c2", "c1", "ar1", new AdjustIn($"adjustment_{Guid.NewGuid()}", "locationA", item))); Assert.IsNotNull(results1.FirstOrDefault(e => e.EventBody is LocationCreated)); Assert.IsNotNull(results2.FirstOrDefault(e => e.EventBody is AdjustedIn)); }
public void AggregateAndStatefulProcessEventsTest() { string firstAggregateId = "ar1"; string secondAggregateId = "ar2"; string firstCommandId = "c1"; string secondCommandId = "c2"; string thirdCommandId = "c3"; string fourthCommandId = "c4"; var item = new StockItem("item", "123"); string movementNumber = $"movement_{Guid.NewGuid()}"; var eventStore = new InMemoryEventStore(); var contextModel = new BoundedContextModel() //.WithAssemblyContaining<Location>() .WithAggregateRoot <Location>() .WithEventHandler <MovedOut, Movement, MoveIn>(e => e.EventBody.Movement.ToString(), c => c.Location) .WithEventHandler <MovedIn, Movement>(e => e.EventBody.Movement.ToString()); var options = new DomainOptions(DomainOption.CacheRuntimeModel); var engine = DomainFactory.CreateDomainExecutionEngine(contextModel, eventStore, options); engine.Process(CommandFactory.Default.CreateCommand <CreateLocation>(firstCommandId, firstCommandId, firstAggregateId, new CreateLocation(firstAggregateId))); engine.Process(CommandFactory.Default.CreateCommand <AdjustIn>(secondCommandId, secondCommandId, firstAggregateId, new AdjustIn($"adjustment_{Guid.NewGuid()}", firstAggregateId, item))); engine.Process(CommandFactory.Default.CreateCommand <CreateLocation>(thirdCommandId, thirdCommandId, secondAggregateId, new CreateLocation(secondAggregateId))); var results = engine.Process(CommandFactory.Default.CreateCommand <MoveOut>(fourthCommandId, fourthCommandId, firstAggregateId, new MoveOut(movementNumber, firstAggregateId, item, secondAggregateId))).ToList(); Assert.IsTrue(results.Count == 2); Assert.IsInstanceOfType(results[0].EventBody, typeof(MovedOut)); Assert.IsTrue(results[0].AggregateId == firstAggregateId); Assert.IsTrue(results[0].AggregateType == typeof(Location).FullName); Assert.IsTrue(results[0].AggregateVersion == 3); Assert.IsTrue(results[0].CommandId == fourthCommandId); Assert.IsTrue(results[0].CorrelationId == fourthCommandId); Assert.IsTrue(results[0].EventBodyType == typeof(MovedOut).FullName); Assert.IsTrue(results[0].Id == $"{firstAggregateId}\\{results[0].AggregateVersion}"); Assert.IsInstanceOfType(results[1].EventBody, typeof(MovedIn)); Assert.IsTrue(results[1].AggregateId == secondAggregateId); Assert.IsTrue(results[1].AggregateType == typeof(Location).FullName); Assert.IsTrue(results[1].AggregateVersion == 2); Assert.IsTrue(results[1].CommandId == $"{typeof(Movement).Name}\\{movementNumber}\\{1}"); Assert.IsTrue(results[1].CorrelationId == fourthCommandId); Assert.IsTrue(results[1].EventBodyType == typeof(MovedIn).FullName); Assert.IsTrue(results[1].Id == $"{secondAggregateId}\\{results[1].AggregateVersion}"); }
/// <summary> /// Method to get a list of products /// </summary> /// <param name="amount">The amount of products we want</param>list /// <returns>List with products</returns> public List <Product> GetListOfProducts(int amount) { List <Product> ProductsList = new List <Product>(); //We iterate through every product and transform them into Product objects foreach (IWebElement aux in GetRawDataOfProducts(5)) { //Getting the raw string where the price is located String RawPriceText = aux.FindElement(By.CssSelector(Strings.RAW_PRICE_TEXT)).Text; //Getting rid off the currency List <String> ValuesOfText = Regex.Split(RawPriceText, @Strings.PRICE_REGEX) .Where(a => a != "." && a.Trim() != "").ToList(); Decimal priceAux = Decimal.Parse(ValuesOfText[0].Trim()); //Getting the raw string where the name is located String NameAux = aux.FindElement(By.CssSelector(Strings.RAW_NAME_TEXT)).Text; //If shipping has a value, we will updated. Otherwise, we will add 0 Decimal shippingAux = 0; /*If the item has a shipping text, and it is * indeed a valid price (no free shipping text or any other label) * we will add it as shipping cost */ if (aux.FindElements(By.CssSelector(Strings.RAW_LOGICIST_COST_TEXT)).Count > 0 && aux.FindElement(By.CssSelector(Strings.RAW_LOGICIST_COST_TEXT)).Text.Any(char.IsDigit)) { String RawShippingText = aux.FindElement(By.CssSelector(Strings.RAW_LOGICIST_COST_TEXT)).Text; //Getting rid off the currency List <String> ValuesOfShipping = Regex.Split(RawShippingText, @Strings.PRICE_REGEX) .Where(a => a != "." && a.Trim() != "").ToList(); //Adding to the list the price shippingAux = Decimal.Parse(ValuesOfShipping[0].Trim()); } //Creating new product Product newProduct = DomainFactory.CreateProduct (NameAux, priceAux, shippingAux); //adding the product to the list ProductsList.Add(newProduct); } return(ProductsList); }
public void testExamplePg296AIMA2e() { FOLDomain domain = DomainFactory.lovesAnimalDomain(); FOLParser parser = new FOLParser(domain); Sentence origSentence = parser .parse("FORALL x (FORALL y (Animal(y) => Loves(x, y)) => EXISTS y Loves(y, x))"); CNFConverter cnfConv = new CNFConverter(parser); CNF cnf = cnfConv.convertToCNF(origSentence); Assert.AreEqual( "[Animal(SF0(x)), Loves(SF1(x),x)],[~Loves(x,SF0(x)), Loves(SF1(x),x)]", cnf.ToString()); }
public void testExamplePg295AIMA2e() { FOLDomain domain = DomainFactory.weaponsDomain(); FOLParser parser = new FOLParser(domain); Sentence origSentence = parser .parse("FORALL x ((((American(x) AND Weapon(y)) AND Sells(x, y, z)) AND Hostile(z)) => Criminal(x))"); CNFConverter cnfConv = new CNFConverter(parser); CNF cnf = cnfConv.convertToCNF(origSentence); Assert.AreEqual( "[~American(x), ~Hostile(z), ~Sells(x,y,z), ~Weapon(y), Criminal(x)]", cnf.ToString()); }
public DomainFactorySpec() { var recorder = new Mock <IRecorder>(); var identifierFactory = new Mock <IIdentifierFactory>(); identifierFactory.Setup(f => f.Create(It.IsAny <IIdentifiableEntity>())) .Returns("anid".ToIdentifier); var dependencyContainer = new Mock <IDependencyContainer>(); dependencyContainer.Setup(dc => dc.Resolve <IRecorder>()) .Returns(recorder.Object); dependencyContainer.Setup(dc => dc.Resolve <IIdentifierFactory>()) .Returns(identifierFactory.Object); this.factory = new DomainFactory(dependencyContainer.Object); }
public void ExeptionIsThrownTest() { string commandId = "c1"; string experimentId = Guid.NewGuid().ToString(); var eventStore = new InMemoryEventStore(); var contextModel = new BoundedContextModel().WithAssemblyContaining <Experiment>(); var options = new DomainOptions(DomainOption.CacheRuntimeModel); var engine = DomainFactory.CreateDomainExecutionEngine(contextModel, eventStore, options); Assert.ThrowsException <ApplicationException>(() => { engine.Process(CommandFactory.Default.CreateCommand <PerformBadExperiment>(commandId, commandId, experimentId, new PerformBadExperiment(true))); }); }
public void ProcessTwoSequentialCommandsUsingDefaultHandlersTest() { var eventStore = new Mock <IEventStore>(); var contextModel = new BoundedContextModel().WithAssemblyContaining <Location>(); eventStore.Setup(x => x.RetrieveById(It.IsAny <string>())).Returns(new Collection <IEvent>()); var engine = DomainFactory.CreateDomainExecutionEngine(contextModel, eventStore.Object, DomainOptions.Defaults); var item = new StockItem("item", "123"); var results1 = engine.Process(CommandFactory.Default.CreateCommand <CreateLocation>("c1", "c1", "ar1", new CreateLocation("locationA"))); var results2 = engine.Process(CommandFactory.Default.CreateCommand <AdjustIn>("c2", "c1", "ar1", new AdjustIn($"adjustment_{Guid.NewGuid()}", "locationA", item))); Assert.IsNotNull(results1.FirstOrDefault(e => e.EventBody is LocationCreated)); Assert.IsNotNull(results2.FirstOrDefault(e => e.EventBody is AdjustedIn)); }
private static void unifierDemo() { FOLParser parser = new FOLParser(DomainFactory.knowsDomain()); Unifier unifier = new Unifier(); IMap <Variable, Term> theta = CollectionFactory.CreateInsertionOrderedMap <Variable, Term>(); Sentence query = parser.parse("Knows(John,x)"); Sentence johnKnowsJane = parser.parse("Knows(y,Mother(y))"); System.Console.WriteLine("------------"); System.Console.WriteLine("Unifier Demo"); System.Console.WriteLine("------------"); IMap <Variable, Term> subst = unifier.unify(query, johnKnowsJane, theta); System.Console.WriteLine("Unify '" + query + "' with '" + johnKnowsJane + "' to get the substitution " + subst + "."); System.Console.WriteLine(""); }
static void fOL_CNFConversion() { System.Console.WriteLine("-------------------------------------------------"); System.Console.WriteLine("Conjuctive Normal Form for First Order Logic Demo"); System.Console.WriteLine("-------------------------------------------------"); FOLDomain domain = DomainFactory.lovesAnimalDomain(); FOLParser parser = new FOLParser(domain); Sentence origSentence = parser.parse("FORALL x (FORALL y (Animal(y) => Loves(x, y)) => EXISTS y Loves(y, x))"); CNFConverter cnfConv = new CNFConverter(parser); CNF cnf = cnfConv.convertToCNF(origSentence); System.Console.WriteLine("Convert '" + origSentence + "' to CNF."); System.Console.WriteLine("CNF=" + cnf.ToString()); System.Console.WriteLine(""); }