Example #1
0
        public void TestFormatToDegreeMinuteSecond()
        {
            Assert.AreEqual("nan", SwissEph.FormatToDegreeMinuteSecond(double.NaN));

            Assert.AreEqual("   0° 0' 0.0000", SwissEph.FormatToDegreeMinuteSecond(0));
            Assert.AreEqual("  12° 9'18.0000", SwissEph.FormatToDegreeMinuteSecond(12.155));
            Assert.AreEqual("  98°45'55.5556", SwissEph.FormatToDegreeMinuteSecond(98.7654321));
            Assert.AreEqual(" -98°45'55.5556", SwissEph.FormatToDegreeMinuteSecond(-98.7654321));
            Assert.AreEqual(" 198°45'55.5556", SwissEph.FormatToDegreeMinuteSecond(198.7654321));
            Assert.AreEqual("-198°45'55.5556", SwissEph.FormatToDegreeMinuteSecond(-198.7654321));

            String format = "D1";

            Assert.AreEqual("   0° 0' 0.0000", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("  12° 9'18.0000", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("  98°45'55.5556", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual(" -98°45'55.5556", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual(" 198°45'55.5556", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("-198°45'55.5556", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "D2";
            Assert.AreEqual("   0° 0' 0\"", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("  12° 9'18\"", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("  98°45'55\"", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual(" -98°45'55\"", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual(" 198°45'55\"", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("-198°45'55\"", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "Z1";
            Assert.AreEqual(" 0 ar  0' 0.0000", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("12 ar  9'18.0000", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual(" 8 cn 45'55.5556", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual(" 8 cn 45'55.5556", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("18 li 45'55.5556", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("18 li 45'55.5556", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "Z2";
            Assert.AreEqual(" 0 ar  0' 0\"", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("12 ar  9'18\"", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual(" 8 cn 45'55\"", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual(" 8 cn 45'55\"", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("18 li 45'55\"", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("18 li 45'55\"", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "[d|dd|ddd|dddd|ddddd]";
            Assert.AreEqual("[0| 0|  0|   0|    0]", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("[12|12| 12|  12|   12]", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("[98|98| 98|  98|   98]", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual("[-98|-98|-98| -98|  -98]", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("[198|198|198| 198|  198]", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("[-198|-198|-198|-198| -198]", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "[D|DD|DDD|DDDD|DDDDD]";
            Assert.AreEqual("[0|00|000|0000|00000]", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("[12|12|012|0012|00012]", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("[98|98|098|0098|00098]", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual("[-98|-98|-98|-098|-0098]", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("[198|198|198|0198|00198]", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("[-198|-198|-198|-198|-0198]", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "[a|aa|aaa|aaaa|aaaaa]";
            Assert.AreEqual("[0| 0|  0|   0|    0]", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("[12|12| 12|  12|   12]", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("[98|98| 98|  98|   98]", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual("[98|98| 98|  98|   98]", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("[198|198|198| 198|  198]", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("[198|198|198| 198|  198]", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "[A|AA|AAA|AAAA|AAAAA]";
            Assert.AreEqual("[0|00|000|0000|00000]", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("[12|12|012|0012|00012]", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("[98|98|098|0098|00098]", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual("[98|98|098|0098|00098]", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("[198|198|198|0198|00198]", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("[198|198|198|0198|00198]", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "[n|nn|nnn|nnnn|nnnnn]";
            Assert.AreEqual("[0| 0|  0|   0|    0]", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("[0| 0|  0|   0|    0]", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("[3| 3|  3|   3|    3]", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual("[3| 3|  3|   3|    3]", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("[6| 6|  6|   6|    6]", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("[6| 6|  6|   6|    6]", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "[N|NN|NNN|NNNN|NNNNN]";
            Assert.AreEqual("[0|00|000|0000|00000]", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("[0|00|000|0000|00000]", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("[3|03|003|0003|00003]", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual("[3|03|003|0003|00003]", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("[6|06|006|0006|00006]", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("[6|06|006|0006|00006]", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "[g|gg|ggg|gggg|ggggg]";
            Assert.AreEqual("[0| 0|  0|   0|    0]", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("[12|12| 12|  12|   12]", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("[8| 8|  8|   8|    8]", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual("[8| 8|  8|   8|    8]", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("[18|18| 18|  18|   18]", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("[18|18| 18|  18|   18]", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "[G|GG|GGG|GGGG|GGGGG]";
            Assert.AreEqual("[0|00|000|0000|00000]", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("[12|12|012|0012|00012]", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("[8|08|008|0008|00008]", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual("[8|08|008|0008|00008]", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("[18|18|018|0018|00018]", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("[18|18|018|0018|00018]", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "[m|mm|mmm|mmmm|mmmmm]";
            Assert.AreEqual("[0| 0|  0|   0|    0]", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("[9| 9|  9|   9|    9]", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("[45|45| 45|  45|   45]", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual("[45|45| 45|  45|   45]", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("[45|45| 45|  45|   45]", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("[45|45| 45|  45|   45]", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "[M|MM|MMM|MMMM|MMMMM]";
            Assert.AreEqual("[0|00|000|0000|00000]", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("[9|09|009|0009|00009]", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("[45|45|045|0045|00045]", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual("[45|45|045|0045|00045]", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("[45|45|045|0045|00045]", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("[45|45|045|0045|00045]", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "[s|ss|sss|ssss|sssss]";
            Assert.AreEqual("[0| 0|  0|   0|    0]", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("[18|18| 18|  18|   18]", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("[55|55| 55|  55|   55]", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual("[55|55| 55|  55|   55]", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("[55|55| 55|  55|   55]", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("[55|55| 55|  55|   55]", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "[S|SS|SSS|SSSS|SSSSS]";
            Assert.AreEqual("[0|00|000|0000|00000]", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("[18|18|018|0018|00018]", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("[55|55|055|0055|00055]", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual("[55|55|055|0055|00055]", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("[55|55|055|0055|00055]", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("[55|55|055|0055|00055]", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "[p|pp|ppp|pppp|ppppp]";
            Assert.AreEqual("[0|00|000|0000|00000]", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("[0|00|000|0000|00000]", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("[6|56|556|5556|55556]", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual("[6|56|556|5556|55556]", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("[6|56|556|5556|55556]", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("[6|56|556|5556|55556]", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "[P|PP|PPP|PPPP|PPPPP]";
            Assert.AreEqual("[0|00|000|0000|00000]", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("[0|00|000|0000|00000]", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("[6|56|556|5556|55556]", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual("[6|56|556|5556|55556]", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("[6|56|556|5556|55556]", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("[6|56|556|5556|55556]", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "[z|zz|zzz|zzzz|zzzzz]";
            Assert.AreEqual("[♈|ar|Aries|Aries|Aries]", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("[♈|ar|Aries|Aries|Aries]", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("[♋|cn|Cancer|Cancer|Cancer]", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual("[♋|cn|Cancer|Cancer|Cancer]", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("[♎|li|Libra|Libra|Libra]", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("[♎|li|Libra|Libra|Libra]", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "[Z|ZZ|ZZZ|ZZZZ|ZZZZZ]";
            Assert.AreEqual("[♈|ar|Aries|Aries|Aries]", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("[♈|ar|Aries|Aries|Aries]", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("[♋|cn|Cancer|Cancer|Cancer]", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual("[♋|cn|Cancer|Cancer|Cancer]", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("[♎|li|Libra|Libra|Libra]", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("[♎|li|Libra|Libra|Libra]", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));

            format = "[-|+]";
            Assert.AreEqual("[| ]", SwissEph.FormatToDegreeMinuteSecond(0, format));
            Assert.AreEqual("[| ]", SwissEph.FormatToDegreeMinuteSecond(12.155, format));
            Assert.AreEqual("[| ]", SwissEph.FormatToDegreeMinuteSecond(98.7654321, format));
            Assert.AreEqual("[-|-]", SwissEph.FormatToDegreeMinuteSecond(-98.7654321, format));
            Assert.AreEqual("[| ]", SwissEph.FormatToDegreeMinuteSecond(198.7654321, format));
            Assert.AreEqual("[-|-]", SwissEph.FormatToDegreeMinuteSecond(-198.7654321, format));
        }