public void MultipleParameterGeneratesCode()
		{
			// Arrange
			IContainer container = new Container ();
			container.Register<ISimpleObject, SimpleObject> ();
			container.Register<IShallowDependent, ShallowDependent> ();
			container.Register<IDeepDependent, DeepDependent> ();
			container.Register<IMultipleParameterObject, MultipleParameterObject> ();
			CodeGenerator codeGenerator = new CodeGenerator ();
			MemoryStream memoryStream = new MemoryStream (); 

			// Act
			codeGenerator.WriteToStream(LanguageEnum.Csharp, container, memoryStream, "SomeNamespace", "TestContainer");
			memoryStream.Position = 0;
			string charpString;
			using (StreamReader reader = new StreamReader(memoryStream)) {
				charpString = reader.ReadToEnd ();
			}
			TestContainer testContainer = new TestContainer ();
			IMultipleParameterObject result = testContainer.Resolve<IMultipleParameterObject> ();

			// Assert
			Assert.IsNotNull (result);
			Assert.IsNotNull (result.ShallowDependent);
			Assert.IsNotNull (result.SimpleObject);
		}
 public void ConstructorNoArgsTest()
 {
     using (TestContainer testContainer = new TestContainer())
     {
         Assert.AreEqual(0, testContainer.services.Count);
         Assert.AreEqual(0, testContainer.profferedServices.Count);
     }
 }
        public void ReadProjectionIndexCheckpointRequests_are_forwarded_to_worker()
        {
            var o = new TestContainer(this);

            var req = new ReadProjectionCheckpointRequest("a");
            o.Reader.Tell(req);

            o.ReadProjectionIndexCheckpointProbe.ExpectMsg<ReadProjectionCheckpointRequest>(m => m == req);
        }
        public void ReadRequests_are_forwarded_to_worker()
        {
            var o = new TestContainer(this);

            var req = new ReadRequest(1, 1);
            o.Reader.Tell(req);

            o.ReadProbe.ExpectMsg<ReadRequest>(m => m == req);
        }
        public void ReadIndexedProjectionStreamRequests_are_forwarded_to_worker()
        {
            var o = new TestContainer(this);

            var req = new ReadIndexedProjectionStreamRequest("a", 1, 1);
            o.Reader.Tell(req);

            o.ReadIndexedProjectionProbe.ExpectMsg<ReadIndexedProjectionStreamRequest>(m => m == req);
        }
        public void JsonSerializerDoesNotEmitMetadata() {
            var container = new TestContainer() { Id = "C7" };
            fsData data;
            (new fsSerializer()).TrySerialize(container, out data);
            var json = fsJsonPrinter.CompressedJson(data);

            // {"Id":"C7","Contents":{"$content":[]}}
            Assert.True(Regex.IsMatch(json, @"C7"));
            Assert.False(Regex.IsMatch(json, @"\$content"));
        }
 public void ConstructorWithServiceProvider()
 {
     MyServiceProvider serviceProvider = new MyServiceProvider();
     using (TestContainer testContainer = new TestContainer(serviceProvider))
     {
         Assert.AreSame(serviceProvider, testContainer.parentServiceProvider);
         Assert.AreEqual(0, testContainer.services.Count);
         Assert.AreEqual(0, testContainer.profferedServices.Count);
     }
 }
 public void AddServiceWithCallback()
 {
     using (TestContainer testContainer = new TestContainer())
     {
         testContainer.AddService(typeof(SayHelloService), new ServiceCreatorCallback(SayHelloServiceCreatorCallback));
         Assert.AreEqual(1, testContainer.services.Count);
         SayHelloService sayHello = testContainer.GetService(typeof(SayHelloService)) as SayHelloService;
         Assert.IsNotNull(sayHello);
         Assert.IsTrue(serviceCallbackExecuted);
     }
 }
Exemple #9
0
 private static void WorkflowTest2()
 {
     var container = new TestContainer();
     var app = new Dumbass(container);
     var result = app.Execute(new Dumbass.CreateEmployee(), new EmployeeModel { Name = "ryuzaki" });
 }
 public void RemoveServiceTest()
 {
     using (TestContainer testContainer = new TestContainer())
     {
         testContainer.AddService(typeof(SayHelloService), new ServiceCreatorCallback(SayHelloServiceCreatorCallback));
         Assert.AreEqual(1, testContainer.services.Count);
         testContainer.RemoveService(typeof(SayHelloService));
         Assert.AreEqual(0, testContainer.services.Count);
     }
 }
Exemple #11
0
 public void Missing_item_and_IfMatch_throw_item_not_found()
 {
     TestContainer.Create();
     ExpectItemNotFound(() => TryToRead(TestItem, StreamingCondition.IfMatch("mismatch")));
 }
Exemple #12
0
        public void Missing_item_throws_item_not_found()
        {
            TestContainer.Create();

            ExpectItemNotFound(() => TryToRead(TestItem));
        }
Exemple #13
0
 public void Unconditional_upsert_works()
 {
     TestContainer.Create();
     Write(TestItem, Guid.Empty);
     Write(TestItem, Guid.Empty);
 }
Exemple #14
0
 public abstract void Run(TestContainer container);
Exemple #15
0
 public bool TryGetContainer(string path, out TestContainer container)
 {
     return(_containers.TryGetValue(path, out container));
 }
Exemple #16
0
        private static void WorkflowTest()
        {
            var container = new TestContainer();
            var app = new Smartass(container);

            Console.WriteLine("Program.Main: ready");
            Console.WriteLine();

            app.Handle(new TheMessage { Message = "Hey amigo!" });

            Console.WriteLine();
            Console.WriteLine("Program.Main: Completed the execution of SuccessMessage");
            Console.WriteLine();

            app.Handle(new TheMessage { Message = "Hey amigo!", ThrowExc = true });

            Console.WriteLine();
            Console.WriteLine("Program.Main: done");
            Console.ReadLine();
        }
Exemple #17
0
 public TestContainer ProvidesContainer(IProvider<TestObject> testObjectProvider)
 {
     return Container = new TestContainer(testObjectProvider);
 }
Exemple #18
0
        bool WriteProjectInfoForContainer(System.Xml.XmlWriter writer, TestContainer container, ILogger log)
        {
            if (container == null)
            {
                return(false);
            }

            string                      nativeCode = "", djangoSettings = "", projectName = "", testFramework = "", unitTestPattern = "", unitTestRootDir = "";
            bool                        isWorkspace     = false;
            ProjectInfo                 projInfo        = null;
            LaunchConfiguration         config          = null;
            Dictionary <string, string> fullEnvironment = null;

            ThreadHelper.JoinableTaskFactory.Run(async() => {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                if (container.Discoverer is TestContainerDiscovererProject)
                {
                    var discoverer = container.Discoverer as TestContainerDiscovererProject;
                    isWorkspace    = discoverer.IsWorkspace;
                    projInfo       = discoverer.GetProjectInfo(container.Project);
                }
                else if (container.Discoverer is TestContainerDiscovererWorkspace)
                {
                    var discoverer = container.Discoverer as TestContainerDiscovererWorkspace;
                    isWorkspace    = discoverer.IsWorkspace;
                    projInfo       = discoverer.GetProjectInfo(container.Project);
                }

                if (projInfo != null)
                {
                    try {
                        config          = projInfo.GetLaunchConfigurationOrThrow();
                        fullEnvironment = LaunchConfigurationUtils.GetFullEnvironment(config, _serviceProvider);
                    } catch {
                    }
                    nativeCode      = projInfo.GetProperty(PythonConstants.EnableNativeCodeDebugging);
                    djangoSettings  = projInfo.GetProperty("DjangoSettingsModule");
                    testFramework   = projInfo.GetProperty(PythonConstants.TestFrameworkSetting);
                    projectName     = projInfo.ProjectName;
                    unitTestRootDir = projInfo.GetProperty(PythonConstants.UnitTestRootDirectorySetting);
                    unitTestPattern = projInfo.GetProperty(PythonConstants.UnitTestPatternSetting);
                }
            });

            if (config == null || projInfo == null)
            {
                log.Log(
                    MessageLevel.Warning,
                    Strings.TestDiscoveryFailedMissingLaunchConfiguration.FormatUI(container.Project)
                    );
                return(false);
            }
            writer.WriteStartElement("Project");
            writer.WriteAttributeString("home", container.Project);
            writer.WriteAttributeString("name", projectName);
            writer.WriteAttributeString("isWorkspace", isWorkspace.ToString());
            writer.WriteAttributeString("useLegacyDebugger", UseLegacyDebugger ? "1" : "0");
            writer.WriteAttributeString("nativeDebugging", nativeCode);
            writer.WriteAttributeString("djangoSettingsModule", djangoSettings);
            writer.WriteAttributeString("testFramework", testFramework);
            writer.WriteAttributeString("workingDir", config.WorkingDirectory);
            writer.WriteAttributeString("interpreter", config.GetInterpreterPath());
            writer.WriteAttributeString("pathEnv", config.Interpreter.PathEnvironmentVariable);
            writer.WriteAttributeString("unitTestRootDir", unitTestRootDir);
            writer.WriteAttributeString("unitTestPattern", unitTestPattern);

            writer.WriteStartElement("Environment");

            Dictionary <string, string> env = fullEnvironment ?? config.Environment;

            foreach (var keyValue in env)
            {
                writer.WriteStartElement("Variable");
                writer.WriteAttributeString("name", keyValue.Key);
                writer.WriteAttributeString("value", keyValue.Value);
                writer.WriteEndElement();
            }
            writer.WriteEndElement(); // Environment

            writer.WriteStartElement("SearchPaths");
            foreach (var path in config.SearchPaths)
            {
                writer.WriteStartElement("Search");
                writer.WriteAttributeString("value", path);
                writer.WriteEndElement();
            }
            writer.WriteEndElement(); // SearchPaths

            return(true);
        }
 public MoqSessionWorkerProcessTestFactory()
 {
     var container = new TestContainer();
     _dataFactory = container.Get<TestDataFactory>();
 }
 public void testNested()
 {
     TestContainer o = new TestContainer();
     o.subObject = new TestSubObject();
     o.subObject.strField1 = "hello";
     JsonExpectationBlock jsonExpectation = (theMock, json) =>
         {
             theMock.JsonStartObject(null, 0);
             int startSubObject = json.IndexOf('{', 1);
             theMock.JsonStartObject("subObject", startSubObject);
             theMock.JsonLeaf("strField1", o.subObject.strField1, true);
             int endSubObject = json.IndexOf('}', startSubObject);
             theMock.JsonEndObject(endSubObject);
             theMock.JsonEndObject(json.Length - 1);
         };
     testInBuiltAndNativeJson(o, jsonExpectation, "test nested json");
 }
        public void ReadHighestGlobalSequenceRequests_are_fowarded_to_worker()
        {
            var o = new TestContainer(this);

            var req = new ReadHighestGlobalSequenceRequest();
            o.Reader.Tell(req);
            o.ReadHighestGlobalSequenceProbe.ExpectMsg<ReadHighestGlobalSequenceRequest>(m => m == req);
        }
 private static IEnumerable <object> GetChildren(TestContainer container)
 {
     return(container.Children);
 }