Esempio n. 1
0
        private void CreatePNUnitServices(
            TestDomain testDomain,
            TestConsoleAccess consoleAccess)
        {
            log.Info("Creating PNUnitServices in the AppDomain of the test");

            object[] param = { mPNUnitTestInfo, consoleAccess };

            try
            {
                System.Runtime.Remoting.ObjectHandle obj
#if NET_2_0
                    = Activator.CreateInstance(
                          testDomain.AppDomain,
#else
                    = testDomain.AppDomain.CreateInstance(
#endif
                          typeof(PNUnitServices).Assembly.FullName,
                          typeof(PNUnitServices).FullName,
                          false, BindingFlags.Default, null, param, null, null, null);
                obj.Unwrap();
            }
            catch (Exception e)
            {
                BuildError(e, consoleAccess);
                log.ErrorFormat("Error running test {0}", e.Message);
                return;
            }
        }
Esempio n. 2
0
        public void LoadAndRunFixtures()
        {
            this.CreateAssembly();

            // load assembly
            using (TestDomain domain = new TestDomain(this.compiler.Parameters.OutputAssembly))
            {
                domain.ShadowCopyFiles = false;
                domain.InitializeEngine();
                foreach (string dir in this.Compiler.Parameters.ReferencedAssemblies)
                {
                    domain.TestEngine.AddHintDirectory(dir);
                }
                domain.PopulateEngine();
                Console.WriteLine("Domain loaded");
                Console.WriteLine("Tree populated, {0} tests", domain.TestEngine.GetTestCount());
                // Assert.AreEqual(1, domain.TestTree.GetTestCount());
                // domain.TestTree.Success+=new MbUnit.Core.RunSuccessEventHandler(TestTree_Success);
                // running tests
                domain.TestEngine.RunPipes();

                // display report
                TextReport report = new TextReport();
                result = domain.TestEngine.Report.Result;
                report.Render(result, Console.Out);
                counter = domain.TestEngine.GetTestCount();
            }
        }
Esempio n. 3
0
 public void AppDomainUnloadedBug()
 {
     TestDomain domain = new TestDomain();
     domain.Load( new TestPackage( "mock-assembly.dll" ) );
     domain.Run(new NullListener());
     domain.Unload();
 }
Esempio n. 4
0
 public static void UnloadTestDomain()
 {
     if ( testDomain != null )
         testDomain.Unload();
     loadedTest = null;
     testDomain = null;
 }
Esempio n. 5
0
 public void AppDomainUnloadedBug()
 {
     TestDomain domain = new TestDomain();
     domain.Load( new TestPackage( mockDll ) );
     domain.Run(new NullListener());
     domain.Unload();
 }
Esempio n. 6
0
        public void GenericDomainSourceOfComposableFunctionIsCorrect()
        {
            var domain    = new TestDomain();
            var arguments = new object[0];

            var source = domain.Source <DateTime>(
                "Namespace", "Function", arguments);

            Assert.Equal(typeof(DateTime), source.ElementType);
            Assert.True(source.Expression is MethodCallExpression);
            var methodCall = source.Expression as MethodCallExpression;

            Assert.Null(methodCall.Object);
            Assert.Equal(typeof(DomainData), methodCall.Method.DeclaringType);
            Assert.Equal("Source", methodCall.Method.Name);
            Assert.Equal(typeof(DateTime), methodCall.Method.GetGenericArguments()[0]);
            Assert.Equal(3, methodCall.Arguments.Count);
            Assert.True(methodCall.Arguments[0] is ConstantExpression);
            Assert.Equal("Namespace", (methodCall.Arguments[0] as ConstantExpression).Value);
            Assert.True(methodCall.Arguments[1] is ConstantExpression);
            Assert.Equal("Function", (methodCall.Arguments[1] as ConstantExpression).Value);
            Assert.True(methodCall.Arguments[2] is ConstantExpression);
            Assert.Equal(arguments, (methodCall.Arguments[2] as ConstantExpression).Value);
            Assert.Equal(source.Expression.ToString(), source.ToString());
        }
Esempio n. 7
0
        public void Run()
        {
            TestDomain domain = new TestDomain();
            Test       test   = domain.LoadAssembly(Path.GetFullPath(_assemblyName), null);

            test.Run(this);
        }
Esempio n. 8
0
        public void Read_Persons_ResponseIsSuccess()
        {
            //arrange
            var persons = new List <Person>();

            for (int i = 1; i <= 10; i++)
            {
                persons.Add(TestDomain.CreatePerson(i));
            }

            PersonContext.Persons.AddRange(persons);
            PersonContext.SaveChanges();

            using (var client = TestHttpClientFactory.Create())
            {
                var personApiUri = new Uri(client.BaseAddress, $"api/{nameof(Person)}/Read");

                //act
                var responseFromGet      = client.GetAsync(personApiUri).Result;
                var returnPersonsFromGet = responseFromGet.Content.ReadAsAsync <List <Person> >().Result;

                //assert
                returnPersonsFromGet.ShouldBeEquivalentTo(persons);
                Assert.That(responseFromGet.IsSuccessStatusCode, Is.True, "response:" + responseFromGet);
            }
        }
Esempio n. 9
0
        public void DisposedDomainBaseCannotAccessContext()
        {
            var domain = new TestDomain();

            domain.Dispose();
            Assert.Throws <ObjectDisposedException>(() => { var configuration = ((IExpandableDomain)domain).Context; });
        }
Esempio n. 10
0
        public void Update_Person_ResponseIsSuccess()
        {
            //arrange
            var person = TestDomain.CreatePerson(1);

            PersonContext.Persons.AddRange(person);
            PersonContext.SaveChanges();


            using (var client = TestHttpClientFactory.Create())
            {
                var personApiUri = new Uri(client.BaseAddress, $"api/{nameof(Person)}");

                //act
                //change the person properties
                person.FirstName = "John";
                person.LastName  = "Doe";
                person.Age       = 99;
                person.Born      = DateTime.Today.AddYears(-99);

                var response     = client.PutAsJsonAsync(personApiUri, person).Result;
                var returnPerson = response.Content.ReadAsAsync <Person>().Result;

                //assert
                returnPerson.ShouldBeEquivalentTo(person);
                Assert.That(PersonContext.Persons.Any(), Is.True);
                Assert.That(response.IsSuccessStatusCode, Is.True, "response:" + response);
            }
        }
        public string Get()
        {
            var testDomain = new TestDomain();

            return(testDomain.Test());
            //return "values";
        }
Esempio n. 12
0
 public void DefaultDomainBaseCanBeCreatedAndDisposed()
 {
     using (var domain = new TestDomain())
     {
         domain.Dispose();
     }
 }
 public void AppDomainUnloadedBug()
 {
     TestDomain domain = new TestDomain();
     domain.Load( new TestPackage( mockDll ) );
     domain.Run(new NullListener(), TestFilter.Empty, false, LoggingThreshold.Off);
     domain.Unload();
 }
Esempio n. 14
0
        public void ShouldModifyTheQueryInExpressionToHaveAnAdditionalWhere()
        {
            //Arrange
            var domain      = new TestDomain();
            var interceptor = new AppendWhere <Foo>(1, foo => foo.Name == "Test", typeof(AllFoos));

            domain.Events = new List <IInterceptor>
            {
                interceptor
            };
            domain.ConnectionString = Settings.Default.Connection;

            //act
            var inMemoryDomainContext = new InMemoryDomainContext <TestDomain>();

            inMemoryDomainContext.Add(new Foo()
            {
                Name = "Test"
            });
            inMemoryDomainContext.Add(new Foo()
            {
                Name = "Should Not Show up"
            });
            inMemoryDomainContext.Commit();
            var repository = new DomainRepository <TestDomain>(inMemoryDomainContext, domain);
            var emptyQuery = new AllFoos();
            var results    = repository.Find(emptyQuery);

            //assert
            results.Count().Should().Be(1);
        }
Esempio n. 15
0
 public void DefaultDomainBaseCanBeCreatedAndDisposed()
 {
     using (var domain = new TestDomain())
     {
         domain.Dispose();
     }
 }
        public void AppDomainUnloadedBug()
        {
            TestDomain domain = new TestDomain();

            domain.Load(new TestPackage("mock-assembly.dll"));
            domain.Run(new NullListener());
            domain.Unload();
        }
Esempio n. 17
0
        public void BinPath()
        {
            string[] assemblies = new string[]
            { @"h:\app1\bin\debug\test1.dll", @"h:\app2\bin\debug\test2.dll", @"h:\app1\bin\debug\test3.dll" };

            Assert.AreEqual(@"h:\app1\bin\debug;h:\app2\bin\debug",
                            TestDomain.GetBinPath(assemblies));
        }
Esempio n. 18
0
        private Test MakeTest(TestDomain testDomain, string assemblyName)
        {
            NUnitProject project;

            project = NUnitProject.FromAssembly(assemblyName);

            return(testDomain.Load(project));
        }
Esempio n. 19
0
        public void MakeAppDomain()
        {
            TextWriter outStream   = new ConsoleWriter(Console.Out);
            TextWriter errorStream = new ConsoleWriter(Console.Error);

            domain = new TestDomain(outStream, errorStream);
            test   = domain.Load("mock-assembly.dll");
        }
Esempio n. 20
0
        private TestRunner MakeTestRunner(string strTestModuleName)
        {
            TestPackage package    = new TestPackage(strTestModuleName);
            TestRunner  testRunner = new TestDomain();

            testRunner.Load(package);
            return(testRunner);
        }
Esempio n. 21
0
        public async Task DomainSubmitAsyncCorrectlyForwardsCall()
        {
            var domain = new TestDomain();

            var submitResult = await domain.SubmitAsync();

            Assert.Same(domain.ChangeSet, submitResult.CompletedChangeSet);
        }
Esempio n. 22
0
        public void AppDomainUnloadedBug()
        {
            TestDomain domain = new TestDomain();

            domain.Load(new TestPackage(mockDll));
            domain.Run(new NullListener(), TestFilter.Empty, false, LoggingThreshold.Off);
            domain.Unload();
        }
Esempio n. 23
0
        public void DomainBaseCannotBeInitializedWithUnrelatedConfiguration()
        {
            var domain           = new TestDomain();
            var expandableDomain = domain as IExpandableDomain;
            var otherConfig      = new DomainConfiguration();

            Assert.Throws <ArgumentException>(() => expandableDomain.Initialize(otherConfig));
        }
Esempio n. 24
0
        private ITest MakeTest(TestDomain testDomain, string assemblyName)
        {
            TestPackage package = new TestPackage(assemblyName);

            package.Settings["ShadowCopyFiles"] = false;

            return(testDomain.Load(package) ? testDomain.Test : null);
        }
Esempio n. 25
0
        private static bool MakeTestFromCommandLine(TestDomain testDomain,
                                                    string testDll)
        {
            ServiceManager.Services.AddService(new DomainManager());
            var package = new TestPackage(testDll);

            return(testDomain.Load(package));
        }
Esempio n. 26
0
        public void AppDomainUnloadedBug()
        {
            TestDomain domain = new TestDomain();

            domain.Load(new TestPackage(mockDll));
            domain.Run(new NullListener());
            domain.Unload();
        }
Esempio n. 27
0
 public void DomainBaseCannotBeInitializedIfAlreadyInitialized()
 {
     var domain = new TestDomain();
     var expandableDomain = domain as IExpandableDomain;
     var derivedConfig = new DomainConfiguration(
         expandableDomain.Configuration);
     var context = expandableDomain.Context;
     Assert.Throws<InvalidOperationException>(() => expandableDomain.Initialize(derivedConfig));
 }
		public void Init()
		{
			domain = new TestDomain();
			TestPackage package = new TestPackage( name );
			package.Assemblies.Add( path1 );
			package.Assemblies.Add( path2 );
			domain.Load( package );
			loadedSuite = domain.Test;
		}
Esempio n. 29
0
        public void AggregateRoot_Increments_Version_For_Each_Applied_Event()
        {
            var root = new TestDomain(SequentialGuid.NewId());

            root.Modify();

            Assert.AreEqual(3, root.Version);
            Assert.AreEqual(3, root.AppliedEvents.Count);
        }
Esempio n. 30
0
 public void DisposedDomainBaseCannotBeInitialized()
 {
     var domain = new TestDomain();
     var expandableDomain = domain as IExpandableDomain;
     var derivedConfig = new DomainConfiguration(
         expandableDomain.Configuration);
     domain.Dispose();
     Assert.Throws<ObjectDisposedException>(() => expandableDomain.Initialize(derivedConfig));
 }
Esempio n. 31
0
        public void AggregateRoot_Calls_Event_Handlers_By_Convention()
        {
            var root = new TestDomain(SequentialGuid.NewId());

            root.Modify();

            Assert.That(root.OnSomethingHappenedCalled);
            Assert.That(root.ApplySomethingElseHappenedCalled);
        }
Esempio n. 32
0
 public void UnloadTestDomain()
 {
     if (testDomain != null)
     {
         testDomain.Unload();
     }
     loadedTest = null;
     testDomain = null;
 }
Esempio n. 33
0
        public async Task DomainQueryAsyncWithSingletonQueryReturnsResult()
        {
            var domain = new TestDomain();

            var result = await domain.QueryAsync(
                domain.Source <string>("Test"), q => q.Single());

            Assert.Equal("Test", result);
        }
Esempio n. 34
0
        public void AggregateRoot_Increments_Version_For_Each_Applied_Event()
        {
            var root = new TestDomain(SequentialGuid.NewId());

            root.Modify();

            Assert.AreEqual(3, root.Version);
            Assert.AreEqual(3, root.AppliedEvents.Count);
        }
Esempio n. 35
0
        public void MakeAppDomain()
        {
            TextWriter outStream   = new ConsoleWriter(Console.Out);
            TextWriter errorStream = new ConsoleWriter(Console.Error);

            testDomain = new TestDomain(outStream, errorStream);

            assemblies = new ArrayList();
        }
        public void Init()
        {
            outStream   = new ConsoleWriter(Console.Out);
            errorStream = new ConsoleWriter(Console.Error);

            domain     = new TestDomain();
            assemblies = new string[]
            { Path.GetFullPath("nonamespace-assembly.dll"), Path.GetFullPath("mock-assembly.dll") };
        }
Esempio n. 37
0
        public void AggregateRoot_Calls_Event_Handlers_By_Convention()
        {
            var root = new TestDomain(SequentialGuid.NewId());

            root.Modify();

            Assert.That(root.OnSomethingHappenedCalled);
            Assert.That(root.ApplySomethingElseHappenedCalled);
        }
Esempio n. 38
0
 public void Init()
 {
     domain = new TestDomain();
     TestPackage package = new TestPackage( name );
     package.Assemblies.Add( path1 );
     package.Assemblies.Add( path2 );
     domain.Load( package );
     loadedSuite = domain.Test;
 }
Esempio n. 39
0
        public async Task DomainQueryAsyncWithQueryReturnsResults()
        {
            var domain = new TestDomain();

            var results = await domain.QueryAsync(
                domain.Source <string>("Test"));

            Assert.True(results.SequenceEqual(new string[] { "Test" }));
        }
Esempio n. 40
0
        public void DomainBaseCannotBeInitializedIfAlreadyInitialized()
        {
            var domain           = new TestDomain();
            var expandableDomain = domain as IExpandableDomain;
            var derivedConfig    = new DomainConfiguration(
                expandableDomain.Configuration);
            var context = expandableDomain.Context;

            Assert.Throws <InvalidOperationException>(() => expandableDomain.Initialize(derivedConfig));
        }
Esempio n. 41
0
 public void DefaultDomainBaseIsConfiguredCorrectly()
 {
     using (var domain = new TestDomain())
     {
         var expandableDomain = domain as IExpandableDomain;
         Assert.NotNull(expandableDomain.Configuration);
         Assert.False(expandableDomain.IsInitialized);
         Assert.NotNull(expandableDomain.Context);
         Assert.True(expandableDomain.IsInitialized);
         Assert.Same(expandableDomain.Configuration,
             expandableDomain.Context.Configuration);
     }
 }
Esempio n. 42
0
 public void LoadFixture()
 {
     TestDomain domain = new TestDomain();
     TestPackage package = new TestPackage( "Multiple Assemblies Test" );
     package.Assemblies.Add(NoNamespaceTestFixture.AssemblyPath);
     package.Assemblies.Add(MockAssembly.AssemblyPath);
     package.TestName = "NUnit.Tests.Assemblies.MockTestFixture";
     try
     {
         domain.Load(package);
         Assert.AreEqual(MockTestFixture.Tests, domain.Test.TestCount);
     }
     finally
     {
         domain.Unload();
     }
 }
Esempio n. 43
0
 public void DisposedDomainBaseCannotAccessContext()
 {
     var domain = new TestDomain();
     domain.Dispose();
     Assert.Throws<ObjectDisposedException>(() => { var configuration = ((IExpandableDomain)domain).Context; });
 }
Esempio n. 44
0
 public void DomainBaseCannotBeInitializedWithUnrelatedConfiguration()
 {
     var domain = new TestDomain();
     var expandableDomain = domain as IExpandableDomain;
     var otherConfig = new DomainConfiguration();
     Assert.Throws<ArgumentException>(() => expandableDomain.Initialize(otherConfig));
 }
		public static void MakeAppDomain()
		{
			testDomain = new TestDomain();
			testDomain.Load( new TestPackage(mockDll));
			loadedTest = testDomain.Test;
		}
Esempio n. 46
0
        public void ExpandedDomainBaseIsInitializedCorrectly()
        {
            var domain = new TestDomain();
            var expandableDomain = domain as IExpandableDomain;
            var derivedConfig = new DomainConfiguration(
                expandableDomain.Configuration);
            derivedConfig.EnsureCommitted();

            expandableDomain.Initialize(derivedConfig);
            Assert.True(expandableDomain.IsInitialized);
            Assert.Same(derivedConfig,
                expandableDomain.Context.Configuration);
        }
Esempio n. 47
0
		internal static IEnumerable<INotation<TestDomain>> AdditionWithMultiplication(Forms alreadyExisting, TestDomain precedenceToken) //a+(b*c)
		{
			Tag = "a+(b*c)";
			var result = LinearNotationFactory.Create(Domain.RealNumber,
													  new TestDomain[] { Domain.RealNumber, Domain.AdditionOperator, Domain.RealNumber, Domain.MultiplicationOperator, Domain.RealNumber },
													  alreadyExisting,
													  GetArtifialType,
													  orderRepresentative: new NotationPrecedenceDelegate<TestDomain>((TestDomain)Domain.ClosingParenthesis, -1));
			EnsureSingleEnumerationDEBUG(ref result);
			Contract.Assert(result.Count() == 1, "The artificial b*c should have been interned and therefore not returned");
			return result;
		}
Esempio n. 48
0
 public static void MakeAppDomain()
 {
     testDomain = new TestDomain();
     testDomain.Load( new TestPackage( "mock-assembly.dll" ) );
     loadedTest = testDomain.Test;
 }
Esempio n. 49
0
		private static TestDomain GetResultOfAST(List<AbstractSyntaxTreeNodeBase<TestDomain.Expression, TestDomain>> nodes, out int operatorIndex)
		{
			operatorIndex = nodes.IndexOf(node => node.Result.DomainKind.IsLiteral());
			if (operatorIndex != -1)
			{
				int start, count;
				var literalResult = nodes[operatorIndex].Result.GetNaryOperatorResult(nodes.Select(node => node.Result), operatorIndex, out start, out count).Value;
				Contract.Assert(start == 0 && count == nodes.Count, "Helper parentheses probably not placed correctly. ");
				return literalResult;
			}

			if (nodes.Count == 3)
			{
				Contract.Assume(nodes[1].Result.IsBinaryOperator());

				operatorIndex = 1;
				var operands = new TestDomain[] { nodes[0].Result, nodes[2].Result };
				return nodes[operatorIndex].Result.GetBinaryOperatorResult(operands[0], operands[1]).Value;
			}
			else if (nodes.Count == 2)
			{
				if (nodes[0].Result.IsOperand())
				{
					if (nodes[1].Result.IsOperand())
						throw new ArgumentException();//probably forgot parenthesis or implicit operators
					operatorIndex = 1;
					return nodes[operatorIndex].Result.GetUnaryOperatorResult(nodes[0].Result).Value;
				}
				else if (nodes[1].Result.IsOperand())
				{
					operatorIndex = 0;
					return nodes[operatorIndex].Result.GetUnaryOperatorResult(nodes[1].Result).Value;
				}
				else if (nodes[0].Result.IsUnaryOperator() && nodes[0].Result.DomainKind == nodes[1].Result.DomainKind)
				{
					if (nodes[0].Result.DomainKind == DomainKind.UnaryPrefix)
					{
						operatorIndex = 0;
						return nodes[operatorIndex].Result.GetUnaryOperatorResult(nodes[1].Result).Value;
					}
					else
					{
						operatorIndex = 1;
						return nodes[operatorIndex].Result.GetUnaryOperatorResult(nodes[0].Result).Value;
					}
				}
				else if (nodes[0].Result.IsUnaryOperator() && nodes[1].Result.IsUnaryOperator())
				{
					if (nodes[0].Result.ComparePrecedenceTo(nodes[1].Result) > 0)
					{
						operatorIndex = 0;
						return nodes[operatorIndex].Result.GetUnaryOperatorResult(nodes[1].Result).Value;
					}
					else
					{
						operatorIndex = 1;
						return nodes[operatorIndex].Result.GetUnaryOperatorResult(nodes[0].Result).Value;
					}
				}
				else throw new Exception();
			}
			else if (nodes.Count == 1)
			{
				throw new ContractException("this case should already have been handled");
			}
			else
				throw new ContractException();
		}
		public void LoadFixture()
		{
			TestDomain domain = new TestDomain();
			TestPackage package = new TestPackage( "Multiple Assemblies Test" );
			package.Assemblies.Add( Path.GetFullPath( "nonamespace-assembly.dll" ) );
			package.Assemblies.Add( Path.GetFullPath( "mock-assembly.dll" ) );
			package.TestName = "NUnit.Tests.Assemblies.MockTestFixture";
            try
            {
                domain.Load(package);
                Assert.AreEqual(MockTestFixture.Tests, domain.Test.TestCount);
            }
            finally
            {
                domain.Unload();
            }
		}
Esempio n. 51
0
 public void UnloadTestDomain()
 {
     domain.Unload();
     domain = null;
 }
 public void CreateRunner()
 {
     domain = new TestDomain();
 }
Esempio n. 53
0
 public void SetUp()
 {
     testDomain = new TestDomain();
 }
Esempio n. 54
0
        public void Context_Publishes_Events()
        {
            var eventStore = new Mock<IEventStore>();
            var eventBus = new Mock<IEventBus>();
            var resolver = new Mock<IDependencyResolver>();

            eventStore.Setup(e => e.Insert(It.IsAny<Guid>(), It.IsAny<List<DomainEvent>>()));
            eventBus.Setup(e => e.PublishEvent(It.IsAny<DomainEvent>()));
            eventBus.Setup(e => e.PublishEvents(It.IsAny<List<DomainEvent>>()));

            resolver.Setup(r => r.Resolve<IEventStore>()).Returns(eventStore.Object);
            resolver.Setup(r => r.Resolve<IEventBus>()).Returns(eventBus.Object);

            var context = new CommandContext(resolver.Object);

            var root = new TestDomain(SequentialGuid.NewId());

            context.Finalize(root);

            eventBus.Verify(e => e.PublishEvents(It.IsAny<List<DomainEvent>>()), Times.Once);
        }
Esempio n. 55
0
        public void AggregateRoot_Defaults_To_New_Id()
        {
            var root = new TestDomain();

            Assert.That(root.Id != Guid.Empty);
        }
Esempio n. 56
0
 public void AllTestDomainsHaveSameConfigurationUntilInvalidated()
 {
     IExpandableDomain domain1 = new TestDomain();
     IExpandableDomain domain2 = new TestDomain();
     Assert.Same(domain2.Configuration, domain1.Configuration);
     DomainConfiguration.Invalidate(domain1.GetType());
     IExpandableDomain domain3 = new TestDomain();
     Assert.NotSame(domain3.Configuration, domain2.Configuration);
 }