示例#1
0
        public void StudioNetworkServer_StudioNetworkServerUnitTest_UpdateMappingChangedMemo_MemoUpdated()
        {
            //init
            var server = new MockEsbHub();
            var message = new CompileMessageTO { UniqueID = Guid.NewGuid(), ServiceID = Guid.NewGuid(), WorkspaceID = Guid.NewGuid(), MessageType = CompileMessageType.MappingChange, MessagePayload = "Test Error Message", ServiceName = "Test Service" };

            //exe
            server.TestOnCompilerMessageReceived(new ICompileMessageTO[] { message });

            //asserts
            Assert.AreEqual(2, server.WriteEventProviderMemos.Count);
            foreach (var memo1 in server.WriteEventProviderMemos)
            {
                var memo = (DesignValidationMemo)memo1;
                Assert.AreEqual(message.ServiceID, memo.ServiceID, "Memo service name not updated with compiler message service name");
                Assert.AreEqual(message.WorkspaceID, memo.WorkspaceID, "Memo workspace ID not updated");
                Assert.IsFalse(memo.IsValid, "Error memo not invalidated");
                Assert.AreEqual(1, memo.Errors.Count, "The wrong number of errors was added to the memo");
                Assert.AreEqual(message.MessagePayload, memo.Errors[0].FixData, "The wrong error fix data was added to the memo");
                Assert.AreEqual(message.UniqueID, memo.Errors[0].InstanceID, "The error instacen ID was added to the memo");
            }

            var serviceMemo = (DesignValidationMemo)server.WriteEventProviderMemos[0];
            var unqiueMemo = (DesignValidationMemo)server.WriteEventProviderMemos[1];
            Assert.AreEqual(message.UniqueID, unqiueMemo.InstanceID, "Memo ID not updated with compiler message unique ID");
            Assert.AreEqual(message.ServiceID, serviceMemo.InstanceID, "Memo ID not updated with compiler message service ID");
        }
示例#2
0
        public void EsbHub_AddItemMessage_ItemHasData_ItemAddedMessageIsPublished()
        {
            //------------Setup for test--------------------------
            var hub         = new MockEsbHub();
            var mockClients = new Mock <IHubCallerConnectionContext <dynamic> >();

            hub.Clients = mockClients.Object;
            dynamic all = new ExpandoObject();
            var     messagePublished = false;

            all.ItemAddedMessage = new Action <string>(serialisedItem =>
            {
                messagePublished = true;
            });
            mockClients.Setup(m => m.All).Returns((ExpandoObject)all);
            //------------Execute Test---------------------------
            hub.AddItemMessage(new ServerExplorerItem
            {
                DisplayName  = "Testing",
                ResourcePath = "Root\\Sub Folder",
                WebserverUri = "http://localhost"
            });
            //------------Assert Results-------------------------
            Assert.IsTrue(messagePublished);
        }
示例#3
0
        public void StudioNetworkServer_StudioNetworkServerUnitTest_UpdateMappingChangedMemo_MemoUpdated()
        {
            //init
            var server  = new MockEsbHub();
            var message = new CompileMessageTO {
                UniqueID = Guid.NewGuid(), ServiceID = Guid.NewGuid(), WorkspaceID = Guid.NewGuid(), MessageType = CompileMessageType.MappingChange, MessagePayload = "Test Error Message", ServiceName = "Test Service"
            };

            //exe
            server.TestOnCompilerMessageReceived(new ICompileMessageTO[] { message });

            //asserts
            Assert.AreEqual(2, server.WriteEventProviderMemos.Count);
            foreach (var memo1 in server.WriteEventProviderMemos)
            {
                var memo = (DesignValidationMemo)memo1;
                Assert.AreEqual(message.ServiceID, memo.ServiceID, "Memo service name not updated with compiler message service name");
                Assert.AreEqual(message.WorkspaceID, memo.WorkspaceID, "Memo workspace ID not updated");
                Assert.IsFalse(memo.IsValid, "Error memo not invalidated");
                Assert.AreEqual(1, memo.Errors.Count, "The wrong number of errors was added to the memo");
                Assert.AreEqual(message.MessagePayload, memo.Errors[0].FixData, "The wrong error fix data was added to the memo");
                Assert.AreEqual(message.UniqueID, memo.Errors[0].InstanceID, "The error instacen ID was added to the memo");
            }

            var serviceMemo = (DesignValidationMemo)server.WriteEventProviderMemos[0];
            var unqiueMemo  = (DesignValidationMemo)server.WriteEventProviderMemos[1];

            Assert.AreEqual(message.UniqueID, unqiueMemo.InstanceID, "Memo ID not updated with compiler message unique ID");
            Assert.AreEqual(message.ServiceID, serviceMemo.InstanceID, "Memo ID not updated with compiler message service ID");
        }
示例#4
0
        public void StudioNetworkServer_StudioNetworkServerUnitTest_UpdateResourceSavedMemo_MemoUpdated()
        {
            //init
            var server = new MockEsbHub();
            var message = new CompileMessageTO { ServiceID = Guid.NewGuid(), WorkspaceID = Guid.NewGuid(), MessageType = CompileMessageType.ResourceSaved, ServiceName = "Test Service" };

            //exe
            server.TestOnCompilerMessageReceived(new ICompileMessageTO[] { message });


            //asserts
            Assert.AreEqual(1, server.WriteEventProviderMemos.Count);

            var memo = (DesignValidationMemo)server.WriteEventProviderMemos[0];
            Assert.AreEqual(message.ServiceID, memo.InstanceID, "Memo ID not updated with compiler message service ID");
            Assert.AreEqual(message.ServiceID, memo.ServiceID, "Memo service name not updated with compiler message service name");
            Assert.AreEqual(message.WorkspaceID, memo.WorkspaceID, "Memo workspace ID not updated");
            Assert.IsTrue(memo.IsValid, "Resource saved with invalid memo");
        }
示例#5
0
        public void EsbHub_AddItemMessage_ItemIsNull_ItemAddedMessageIsNotPublished()
        {
            //------------Setup for test--------------------------
            var hub         = new MockEsbHub();
            var mockClients = new Mock <IHubCallerConnectionContext <dynamic> >();

            hub.Clients = mockClients.Object;
            dynamic all = new ExpandoObject();
            var     messagePublished = false;

            all.ItemAddedMessage = new Action <string>(serialisedItem =>
            {
                messagePublished = true;
            });
            mockClients.Setup(m => m.All).Returns((ExpandoObject)all);
            //------------Execute Test---------------------------
            hub.AddItemMessage(null);
            //------------Assert Results-------------------------
            Assert.IsFalse(messagePublished);
        }
示例#6
0
        public void StudioNetworkServer_StudioNetworkServerUnitTest_UpdateResourceSavedMemo_MemoUpdated()
        {
            //init
            var server  = new MockEsbHub();
            var message = new CompileMessageTO {
                ServiceID = Guid.NewGuid(), WorkspaceID = Guid.NewGuid(), MessageType = CompileMessageType.ResourceSaved, ServiceName = "Test Service"
            };

            //exe
            server.TestOnCompilerMessageReceived(new ICompileMessageTO[] { message });


            //asserts
            Assert.AreEqual(1, server.WriteEventProviderMemos.Count);

            var memo = (DesignValidationMemo)server.WriteEventProviderMemos[0];

            Assert.AreEqual(message.ServiceID, memo.InstanceID, "Memo ID not updated with compiler message service ID");
            Assert.AreEqual(message.ServiceID, memo.ServiceID, "Memo service name not updated with compiler message service name");
            Assert.AreEqual(message.WorkspaceID, memo.WorkspaceID, "Memo workspace ID not updated");
            Assert.IsTrue(memo.IsValid, "Resource saved with invalid memo");
        }
示例#7
0
 public void EsbHub_AddItemMessage_ItemHasData_ItemAddedMessageIsPublished()
 {
     //------------Setup for test--------------------------
     var hub = new MockEsbHub();
     var mockClients = new Mock<IHubCallerConnectionContext<dynamic>>();
     hub.Clients = mockClients.Object;
     dynamic all = new ExpandoObject();
     bool messagePublished = false;
     all.ItemAddedMessage = new Action<string>(serialisedItem =>
     {
         messagePublished = true;
     });
     mockClients.Setup(m => m.Others).Returns((ExpandoObject)all);
     //------------Execute Test---------------------------
     hub.AddItemMessage(new ServerExplorerItem
         {
             DisplayName = "Testing",
             ResourcePath = "Root\\Sub Folder",
             WebserverUri = "http://localhost"
         });
     //------------Assert Results-------------------------
     Assert.IsTrue(messagePublished);
 }
示例#8
0
 public void EsbHub_AddItemMessage_ItemIsNull_ItemAddedMessageIsNotPublished()
 {
     //------------Setup for test--------------------------
     var hub = new MockEsbHub();
     var mockClients = new Mock<IHubCallerConnectionContext<dynamic>>();
     hub.Clients = mockClients.Object;
     dynamic all = new ExpandoObject();
     bool messagePublished = false;
     all.ItemAddedMessage = new Action<string>(serialisedItem =>
     {
         messagePublished = true;
     });
     mockClients.Setup(m => m.All).Returns((ExpandoObject)all);
     //------------Execute Test---------------------------
     hub.AddItemMessage(null);
     //------------Assert Results-------------------------
     Assert.IsFalse(messagePublished);
 }