public void SearchCommand_ExecuteRequest_2()
        {
            int returnCode = 0;
            Mock <IIrbisConnection> mock       = GetConnectionMock();
            IIrbisConnection        connection = mock.Object;
            SearchCommand           command    = new SearchCommand(connection)
            {
                Database                = "IBIS",
                SearchExpression        = "A=AUTHOR$",
                MinMfn                  = 0,
                MaxMfn                  = 0,
                SequentialSpecification = "p(v300)",
                FormatSpecification     = "(v300/)"
            };
            ResponseBuilder builder = new ResponseBuilder()
                                      .StandardHeader(CommandCode.Search, 123, 456)
                                      .NewLine()
                                      .Append(returnCode)
                                      .NewLine()
                                      .Append(0)
                                      .NewLine();
            TestingSocket socket = (TestingSocket)connection.Socket;

            socket.Response = builder.Encode();
            ClientQuery    query    = command.CreateQuery();
            ServerResponse response = command.Execute(query);

            Assert.AreEqual(returnCode, response.ReturnCode);
            Assert.IsNotNull(command.Found);
            Assert.AreEqual(0, command.Found.Count);
        }
        public void ConnectCommand_ExecuteRequest_2()
        {
            int    returnCode            = 0;
            string configuration         = "Some=Text";
            Mock <IIrbisConnection> mock = GetConnectionMock();

            mock.SetupGet(c => c.Connected).Returns(true);
            IIrbisConnection connection = mock.Object;
            ConnectCommand   command    = new ConnectCommand(connection)
            {
                Username = "******",
                Password = "******"
            };
            ResponseBuilder builder = new ResponseBuilder()
                                      .AppendAnsi(CommandCode.RegisterClient).NewLine()
                                      .AppendAnsi("12345678").NewLine()
                                      .AppendAnsi("1").NewLine()
                                      .AppendAnsi("123").NewLine()
                                      .AppendAnsi("64.2014").NewLine()
                                      .NewLine()
                                      .NewLine()
                                      .NewLine()
                                      .NewLine()
                                      .NewLine()
                                      .Append(returnCode).NewLine()
                                      .AppendAnsi("30").NewLine()
                                      .AppendAnsi(configuration);
            TestingSocket socket = (TestingSocket)connection.Socket;

            socket.Response = builder.Encode();
            ClientQuery query = command.CreateQuery();

            command.Execute(query);
        }
        public void ReadPostingsCommand_ExecuteRequest_1()
        {
            int returnCode = 0;
            Mock <IIrbisConnection> mock       = GetConnectionMock();
            IIrbisConnection        connection = mock.Object;
            ReadPostingsCommand     command    = new ReadPostingsCommand(connection)
            {
                Database    = "IBIS",
                ListOfTerms = new []
                {
                    "FIRST",
                    "SECOND",
                    "THIRD"
                }
            };
            ResponseBuilder builder = new ResponseBuilder()
                                      .StandardHeader(CommandCode.ReadPostings, 123, 456)
                                      .NewLine()
                                      .Append(returnCode)
                                      .NewLine();
            TestingSocket socket = (TestingSocket)connection.Socket;

            socket.Response = builder.Encode();
            ClientQuery    query    = command.CreateQuery();
            ServerResponse response = command.Execute(query);

            Assert.AreEqual(returnCode, response.ReturnCode);
        }
        public void ReadFileCommand_ExecuteRequest_1()
        {
            int returnCode = 0;
            Mock <IIrbisConnection> mock       = GetConnectionMock();
            IIrbisConnection        connection = mock.Object;
            ReadFileCommand         command    = new ReadFileCommand(connection)
            {
                Files =
                {
                    new FileSpecification(IrbisPath.MasterFile, "IBIS", "file.txt")
                }
            };
            ResponseBuilder builder = new ResponseBuilder()
                                      .StandardHeader(CommandCode.ReadDocument, 123, 456)
                                      .NewLine()
                                      .Append(returnCode)
                                      .NewLine();
            TestingSocket socket = (TestingSocket)connection.Socket;

            socket.Response = builder.Encode();
            ClientQuery    query    = command.CreateQuery();
            ServerResponse response = command.Execute(query);

            Assert.IsNotNull(response);
        }
Esempio n. 5
0
        public void NopCommand_ExecuteRequest_1()
        {
            Mock <IIrbisConnection> mock       = GetConnectionMock();
            IIrbisConnection        connection = mock.Object;
            NopCommand      command            = new NopCommand(connection);
            ResponseBuilder builder            = new ResponseBuilder()
                                                 .StandardHeader(CommandCode.Nop, 123, 456)
                                                 .NewLine()
                                                 .Append(0)
                                                 .NewLine();
            TestingSocket socket = (TestingSocket)connection.Socket;

            socket.Response = builder.Encode();
            ClientQuery    query    = command.CreateQuery();
            ServerResponse response = command.Execute(query);

            Assert.AreEqual(0, response.ReturnCode);
        }
Esempio n. 6
0
        public void MaxMfnCommand_ExecuteRequest_1()
        {
            int maxMfn = 123456;
            Mock <IIrbisConnection> mock       = GetConnectionMock();
            IIrbisConnection        connection = mock.Object;
            MaxMfnCommand           command    = new MaxMfnCommand(connection)
            {
                Database = "IBIS"
            };
            ResponseBuilder builder = new ResponseBuilder()
                                      .StandardHeader(CommandCode.GetMaxMfn, 123, 456)
                                      .NewLine()
                                      .Append(maxMfn)
                                      .NewLine();
            TestingSocket socket = (TestingSocket)connection.Socket;

            socket.Response = builder.Encode();
            ClientQuery    query    = command.CreateQuery();
            ServerResponse response = command.Execute(query);

            Assert.AreEqual(maxMfn, response.ReturnCode);
        }
        public void CreateDatabaseCommand_ExecuteRequest_1()
        {
            int returnCode = 0;
            Mock <IIrbisConnection> mock       = GetConnectionMock();
            IIrbisConnection        connection = mock.Object;
            CreateDatabaseCommand   command    = new CreateDatabaseCommand(connection)
            {
                Database    = "NEWIBIS",
                Description = "New catalog"
            };
            ResponseBuilder builder = new ResponseBuilder()
                                      .StandardHeader(CommandCode.CreateDatabase, 123, 456)
                                      .NewLine()
                                      .Append(returnCode)
                                      .NewLine();
            TestingSocket socket = (TestingSocket)connection.Socket;

            socket.Response = builder.Encode();
            ClientQuery    query    = command.CreateQuery();
            ServerResponse response = command.Execute(query);

            Assert.AreEqual(returnCode, response.ReturnCode);
        }
        public void ConnectCommand_ExecuteRequest_1()
        {
            int    returnCode                  = 0;
            string configuration               = "Some=Text";
            Mock <IIrbisConnection> mock       = GetConnectionMock();
            IIrbisConnection        connection = mock.Object;
            ConnectCommand          command    = new ConnectCommand(connection)
            {
                Username = "******",
                Password = "******"
            };
            ResponseBuilder builder = new ResponseBuilder()
                                      .AppendAnsi(CommandCode.RegisterClient).NewLine()
                                      .AppendAnsi("12345678").NewLine()
                                      .AppendAnsi("1").NewLine()
                                      .AppendAnsi("123").NewLine()
                                      .AppendAnsi("64.2014").NewLine()
                                      .NewLine()
                                      .NewLine()
                                      .NewLine()
                                      .NewLine()
                                      .NewLine()
                                      .Append(returnCode).NewLine()
                                      .AppendAnsi("30").NewLine()
                                      .AppendAnsi(configuration);
            TestingSocket socket = (TestingSocket)connection.Socket;

            socket.Response = builder.Encode();
            ClientQuery    query    = command.CreateQuery();
            ServerResponse response = command.Execute(query);

            Assert.AreEqual(returnCode, response.ReturnCode);
            Assert.AreEqual(configuration, command.Configuration);
            Assert.AreEqual(30, command.ConfirmationInterval);
            Assert.AreEqual("64.2014", command.ServerVersion);
        }