Example #1
0
        public void BatchAccessor_ReadRecords_1()
        {
            Mock <IIrbisConnection> mock       = GetMock();
            IIrbisConnection        connection = mock.Object;
            BatchAccessor           batch      = new BatchAccessor(connection);

            int[]        mfnList = new int[0];
            MarcRecord[] records = batch.ReadRecords("IBIS", mfnList);
            Assert.AreEqual(0, records.Length);
        }
Example #2
0
        public void BatchAccessor_ReadRecords_7()
        {
            Mock <IIrbisConnection> mock       = new Mock <IIrbisConnection>();
            IIrbisConnection        connection = mock.Object;

            mock.SetupGet(c => c.CommandFactory)
            .Returns(new CommandFactory(connection));
            mock.Setup(c => c.ExecuteCommand(It.IsAny <AbstractCommand>()))
            .Returns((FormatCommand command)
                     => ExecuteFormatCommand(command, true));
            BatchAccessor batch = new BatchAccessor(connection);

            int[] mfnList = { 1, 2, 3 };
            batch.ReadRecords("IBIS", mfnList);
        }
Example #3
0
        public void BatchAccessor_ReadRecords_2()
        {
            Mock <IIrbisConnection> mock       = GetMock();
            IIrbisConnection        connection = mock.Object;
            BatchAccessor           batch      = new BatchAccessor(connection);

            int[]        mfnList = { 1 };
            MarcRecord[] records = batch.ReadRecords("IBIS", mfnList);
            Assert.AreEqual(1, records.Length);
            Assert.AreEqual(1, records[0].Mfn);

            mock.Verify(c => c.ReadRecord(It.IsAny <string>(),
                                          It.IsAny <int>(), It.IsAny <bool>(),
                                          It.IsAny <string>()), Times.Once);
        }
Example #4
0
        public void BatchAccessor_ReadRecords_4()
        {
            Mock <IIrbisConnection> mock       = GetMock();
            IIrbisConnection        connection = mock.Object;
            BatchAccessor           batch      = new BatchAccessor(connection);

            int[] mfnList = new int[0];
            int[] records = batch.ReadRecords("IBIS", mfnList, RecordToMfn);
            Assert.AreEqual(0, records.Length);

            mock.Verify(c => c.ReadRecord(It.IsAny <string>(),
                                          It.IsAny <int>(), It.IsAny <bool>(),
                                          It.IsAny <string>()), Times.Never);
            mock.Verify(c => c.ExecuteCommand(It.IsAny <AbstractCommand>()),
                        Times.Never);
        }
Example #5
0
        public void BatchAccessor_ReadRecords_3()
        {
            Mock <IIrbisConnection> mock       = GetMock();
            IIrbisConnection        connection = mock.Object;
            BatchAccessor           batch      = new BatchAccessor(connection);

            int[]        mfnList = { 1, 2, 3 };
            MarcRecord[] records = batch.ReadRecords("IBIS", mfnList);
            Assert.AreEqual(3, records.Length);
            records = records.OrderBy(record => record.Mfn).ToArray();
            Assert.AreEqual(1, records[0].Mfn);
            Assert.AreEqual(2, records[1].Mfn);
            Assert.AreEqual(3, records[2].Mfn);

            mock.Verify(c => c.ReadRecord(It.IsAny <string>(),
                                          It.IsAny <int>(), It.IsAny <bool>(),
                                          It.IsAny <string>()), Times.Never);
            mock.Verify(c => c.ExecuteCommand(It.IsAny <AbstractCommand>()),
                        Times.Once);
        }