Exemple #1
0
        public void Add_Adds_OperationFile_To_OperationFiles()
        {
            // Arrange
            var index         = new OperationsIndex();
            var operation     = new Operation("Test", "1234", DateTime.Now);
            var operationFile = new OperationFile(operation, "fileName.test");

            // Act
            index.Add(operationFile);
            var result = index.OperationFiles.ToList();

            // Assert
            Assert.That(result.Count, Is.EqualTo(1));
        }
Exemple #2
0
        public void Update_Throws_If_Operation_Was_Not_Found_In_Index()
        {
            // Arrange
            var operation = new Operation("Test", "1234", DateTime.Now);
            var fileName  = $"{operation.Id}.sod";

            var index = new OperationsIndex();

            index.Add(new OperationFile(operation, fileName));
            this.indexDataAccessMock
            .Setup(x => x.Read(It.IsAny <string>()))
            .Returns(index);

            // Act // Assert
            Assert.Throws <KeyNotFoundException>(
                () => this.repository.Update(new Operation("Test 2", "0000", DateTime.Now)));
        }
Exemple #3
0
        public void Update_Calls_Index_DataAccess_Read()
        {
            // Arrange
            var operation = new Operation("Test", "1234", DateTime.Now);
            var fileName  = $"{operation.Id}.sod";

            var index = new OperationsIndex();

            index.Add(new OperationFile(operation, fileName));
            this.indexDataAccessMock
            .Setup(x => x.Read(It.IsAny <string>()))
            .Returns(index);

            // Act
            this.repository.Update(operation);

            // Assert
            this.indexDataAccessMock.Verify(x => x.Read(It.IsAny <string>()), Times.Once);
        }
Exemple #4
0
        public void Read_Returns_Operaton()
        {
            // Arrange
            var operation = new Operation("Test", "1234", DateTime.Now);

            this.dataAccessMock
            .Setup(x => x.Read(It.IsAny <string>())).Returns(operation);
            var index = new OperationsIndex();
            var file  = new OperationFile(operation, "TestOperationIndex.dat");

            index.Add(file);
            this.indexDataAccessMock
            .Setup(x => x.Read(It.IsAny <string>())).Returns(index);

            // Act
            var result = this.repository.Read(operation.Id);

            // Assert
            Assert.That(operation, Is.Not.Null);
        }