Exemple #1
0
        public void ShouldReturnErrorIfIPassNullFileName()
        {
            // arrange
            LoadSchematicRequest request        = null;
            ISchematicServices   implementation = null;
            var service = new SchematicServices(implementation);

            // act
            Assert.Throws <System.ArgumentNullException>(() => service.LoadSchematicFromFile(request));
        }
Exemple #2
0
        public LoadSchematicResponse LoadSchematicFromFile(LoadSchematicRequest request)
        {
            ThrowIf.Argument.IsNull(request, "request");
            ThrowIf.Argument.IsNull(request.Path, "path");
            if (!services.FileExists(request.Path))
            {
                throw new FileNotFoundException();
            }

            return(new LoadSchematicResponse()
            {
                Schematic = services.LoadSchematicFromFile(request.Path)
            });
        }
Exemple #3
0
        public void ShouldReturnErrorIfIPassBadFileName()
        {
            // arrange
            var request = new LoadSchematicRequest
            {
                Path = "goodFile.schematic"
            };

            var badRequest = new LoadSchematicRequest
            {
                Path = "bad.schematic"
            };
            ISchematicServices implementation = getServiceImplementation(request.Path);
            var service = new SchematicServices(implementation);

            // act
            Assert.Throws <System.IO.FileNotFoundException>(() => service.LoadSchematicFromFile(badRequest));
        }
Exemple #4
0
        public void ShouldWorkInHappyCase()
        {
            // arrange
            var request = new LoadSchematicRequest
            {
                Path = "goodFile.schematic"
            };

            ISchematicServices implementation = getServiceImplementation(request.Path);
            var service = new SchematicServices(implementation);

            // act
            var response = service.LoadSchematicFromFile(request);

            // assert
            Assert.IsTrue(response != null, "response should be defined");
            implementation.Received().LoadSchematicFromFile(request.Path);
        }