コード例 #1
0
        public void GetDetailFor1Arg()
        {
            var reader = new FileDataReader(_fileData);

            var result = Assert.Throws <ArgumentException>(() => reader.GetDetail(new string[] { "-v" }));

            Assert.NotNull(result);
            Assert.Equal($"Two arguments must be provided: the first to define the mode, the second to specify the file.{Environment.NewLine}Arguments recieved: '-v'", result.Message);
        }
コード例 #2
0
        public void GetDetailForValidSizeStrings(string detailTypeString)
        {
            var reader = new FileDataReader(_fileData);

            var result = reader.GetDetail(detailTypeString, "c:/test.txt");

            Assert.NotNull(result);
            Assert.NotEmpty(result);
            Assert.True(int.TryParse(result, out int size));    //the size string can be parsed as an int
        }
コード例 #3
0
        public void GetDetailForInvalidStrings_argsArray(string detailTypeString)
        {
            var reader = new FileDataReader(_fileData);

            var result = Assert.Throws <ArgumentException>(() => reader.GetDetail(new string[] { detailTypeString, "c:/test.txt" }));

            Assert.NotNull(result);
            Assert.Contains(detailTypeString, result.Message);
            Assert.Equal($"'{detailTypeString}' is not a valid detail type argument.{Environment.NewLine}" +
                         $"Please use '-v' or '--version' as the first argument to read the file version or '-s' or '--size' as the first argument to read the file size.", result.Message);
        }
コード例 #4
0
        public void GetDetailForValidVersionStrings_argsArray(string detailTypeString)
        {
            var reader = new FileDataReader(_fileData);

            var result = reader.GetDetail(new string[] { detailTypeString, "c:/test.txt" });

            Assert.NotNull(result);
            Assert.NotEmpty(result);
            var parts = result.Split('.');

            Assert.Equal(3, parts.Length);                               //there are three parts
            Assert.All(parts, p =>
                       Assert.True(int.TryParse(p, out int versionPart)) //each part can be parsed as an int.
                       );
        }