Esempio n. 1
0
		/// <summary>
		/// Records any exception which is thrown by the given code.
		/// </summary>
		/// <param name="code">The code which may thrown an exception.</param>
		/// <returns>Returns the exception that was thrown by the code; null, otherwise.</returns>
		public static Exception Exception(Assert.ThrowsDelegate code)
		{
			try
			{
				code();
				return null;
			}
			catch (Exception ex)
			{
				return ex;
			}
		}
 public static void IsInstanceOf(Type expectedType, object o)
 {
     XAssert.IsType(expectedType, o);
 }
Esempio n. 3
0
 public static void AreEqual <T>(IEnumerable <T> expected, IEnumerable <T> actual)
 {
     XAssert.Equal(expected, actual);
 }
Esempio n. 4
0
 public static void IsNotNull(object o)
 {
     XAssert.NotNull(o);
 }
Esempio n. 5
0
 public static void AreNotEqual <T>(T expected, T actual, string message = null)
 {
     XAssert.NotEqual(expected, actual);
 }
        public async Task IsTriggered_ExecutesCorrectly()
        {
            var handler = GetTriggerHandlerInstance();

            //any status combination
            var parameters = new InvoiceStatusChangedTriggerParameters()
            {
                Conditions = InvoiceStatusChangedController.AllowedStatuses.Select(item => new InvoiceStatusChangeCondition()
                {
                    Status            = item.Value,
                    ExceptionStatuses = InvoiceStatusChangedController.AllowedExceptionStatus.Select(item2 => item2.Value).ToList()
                }).ToList()
            };

            Assert.True(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
            {
                Data = new InvoiceStatusChangedTriggerData()
                {
                    ExternalServiceId = "A",
                    Invoice           = new BtcPayInvoice()
                    {
                        Status         = BtcPayInvoice.STATUS_NEW,
                        CurrentTime    = DateTimeOffset.Now,
                        InvoiceTime    = DateTimeOffset.Now,
                        ExpirationTime = DateTimeOffset.Now
                    }
                }
            },
                                                  new RecipeTrigger()
            {
                TriggerId         = handler.TriggerId,
                ExternalServiceId = "A",
                DataJson          = JsonConvert.SerializeObject(parameters)
            }));

            //the external service id is not the same, if it triggers you are in deep shit
            Assert.False(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
            {
                Data = new InvoiceStatusChangedTriggerData()
                {
                    ExternalServiceId = "B",
                    Invoice           = new BtcPayInvoice()
                    {
                        Status         = BtcPayInvoice.STATUS_NEW,
                        CurrentTime    = DateTimeOffset.Now,
                        InvoiceTime    = DateTimeOffset.Now,
                        ExpirationTime = DateTimeOffset.Now
                    }
                }
            },
                                                   new RecipeTrigger()
            {
                TriggerId         = handler.TriggerId,
                ExternalServiceId = "A",
                DataJson          = JsonConvert.SerializeObject(parameters)
            }));

            Assert.True(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
            {
                Data = new InvoiceStatusChangedTriggerData()
                {
                    ExternalServiceId = "A",
                    Invoice           = new BtcPayInvoice()
                    {
                        Status         = BtcPayInvoice.STATUS_PAID,
                        CurrentTime    = DateTimeOffset.Now,
                        InvoiceTime    = DateTimeOffset.Now,
                        ExpirationTime = DateTimeOffset.Now
                    }
                }
            },
                                                  new RecipeTrigger()
            {
                TriggerId         = handler.TriggerId,
                ExternalServiceId = "A",
                DataJson          = JsonConvert.SerializeObject(parameters)
            }));

            Assert.True(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
            {
                Data = new InvoiceStatusChangedTriggerData()
                {
                    ExternalServiceId = "A",
                    Invoice           = new BtcPayInvoice()
                    {
                        Status          = BtcPayInvoice.STATUS_INVALID,
                        ExceptionStatus = new JValue(Invoice.EXSTATUS_PAID_PARTIAL),
                        CurrentTime     = DateTimeOffset.Now,
                        InvoiceTime     = DateTimeOffset.Now,
                        ExpirationTime  = DateTimeOffset.Now
                    }
                }
            },
                                                  new RecipeTrigger()
            {
                TriggerId         = handler.TriggerId,
                ExternalServiceId = "A",
                DataJson          = JsonConvert.SerializeObject(parameters)
            }));

            //only paid status with no exception statuses
            parameters.Conditions = new List <InvoiceStatusChangeCondition>()
            {
                new InvoiceStatusChangeCondition()
                {
                    Status            = Invoice.STATUS_PAID,
                    ExceptionStatuses = new List <string>()
                    {
                        Invoice.EXSTATUS_FALSE
                    }
                }
            };

            Assert.True(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
            {
                Data = new InvoiceStatusChangedTriggerData()
                {
                    ExternalServiceId = "A",
                    Invoice           = new BtcPayInvoice()
                    {
                        Status         = BtcPayInvoice.STATUS_PAID,
                        CurrentTime    = DateTimeOffset.Now,
                        InvoiceTime    = DateTimeOffset.Now,
                        ExpirationTime = DateTimeOffset.Now
                    }
                }
            },
                                                  new RecipeTrigger()
            {
                TriggerId         = handler.TriggerId,
                ExternalServiceId = "A",
                DataJson          = JsonConvert.SerializeObject(parameters)
            }));

            Assert.False(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
            {
                Data = new InvoiceStatusChangedTriggerData()
                {
                    ExternalServiceId = "A",
                    Invoice           = new BtcPayInvoice()
                    {
                        Status          = BtcPayInvoice.STATUS_PAID,
                        ExceptionStatus = Invoice.EXSTATUS_PAID_PARTIAL,
                        CurrentTime     = DateTimeOffset.Now,
                        InvoiceTime     = DateTimeOffset.Now,
                        ExpirationTime  = DateTimeOffset.Now
                    }
                }
            },
                                                   new RecipeTrigger()
            {
                TriggerId         = handler.TriggerId,
                ExternalServiceId = "A",
                DataJson          = JsonConvert.SerializeObject(parameters)
            }));

            Assert.False(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
            {
                Data = new InvoiceStatusChangedTriggerData()
                {
                    ExternalServiceId = "A",
                    Invoice           = new BtcPayInvoice()
                    {
                        Status         = BtcPayInvoice.STATUS_NEW,
                        CurrentTime    = DateTimeOffset.Now,
                        InvoiceTime    = DateTimeOffset.Now,
                        ExpirationTime = DateTimeOffset.Now
                    }
                }
            },
                                                   new RecipeTrigger()
            {
                TriggerId         = handler.TriggerId,
                ExternalServiceId = "A",
                DataJson          = JsonConvert.SerializeObject(parameters)
            }));

            parameters.Conditions = new List <InvoiceStatusChangeCondition>()
            {
                new InvoiceStatusChangeCondition()
                {
                    Status            = Invoice.STATUS_PAID,
                    ExceptionStatuses = new List <string>()
                    {
                        Invoice.EXSTATUS_FALSE
                    }
                },
                new InvoiceStatusChangeCondition()
                {
                    Status            = Invoice.STATUS_INVALID,
                    ExceptionStatuses = new List <string>()
                    {
                        "paidLate"
                    }
                }
            };

            Assert.False(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
            {
                Data = new InvoiceStatusChangedTriggerData()
                {
                    ExternalServiceId = "A",
                    Invoice           = new BtcPayInvoice()
                    {
                        Status         = BtcPayInvoice.STATUS_INVALID,
                        CurrentTime    = DateTimeOffset.Now,
                        InvoiceTime    = DateTimeOffset.Now,
                        ExpirationTime = DateTimeOffset.Now
                    }
                }
            },
                                                   new RecipeTrigger()
            {
                TriggerId         = handler.TriggerId,
                ExternalServiceId = "A",
                DataJson          = JsonConvert.SerializeObject(parameters)
            }));
            Assert.False(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
            {
                Data = new InvoiceStatusChangedTriggerData()
                {
                    ExternalServiceId = "A",
                    Invoice           = new BtcPayInvoice()
                    {
                        Status          = BtcPayInvoice.STATUS_PAID,
                        ExceptionStatus = Invoice.EXSTATUS_PAID_OVER,
                        CurrentTime     = DateTimeOffset.Now,
                        InvoiceTime     = DateTimeOffset.Now,
                        ExpirationTime  = DateTimeOffset.Now
                    }
                }
            },
                                                   new RecipeTrigger()
            {
                TriggerId         = handler.TriggerId,
                ExternalServiceId = "A",
                DataJson          = JsonConvert.SerializeObject(parameters)
            }));

            Assert.True(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
            {
                Data = new InvoiceStatusChangedTriggerData()
                {
                    ExternalServiceId = "A",
                    Invoice           = new BtcPayInvoice()
                    {
                        Status          = BtcPayInvoice.STATUS_PAID,
                        ExceptionStatus = Invoice.EXSTATUS_FALSE,
                        CurrentTime     = DateTimeOffset.Now,
                        InvoiceTime     = DateTimeOffset.Now,
                        ExpirationTime  = DateTimeOffset.Now
                    }
                }
            },
                                                  new RecipeTrigger()
            {
                TriggerId         = handler.TriggerId,
                ExternalServiceId = "A",
                DataJson          = JsonConvert.SerializeObject(parameters)
            }));
            Assert.True(await handler.IsTriggered(new InvoiceStatusChangedTrigger()
            {
                Data = new InvoiceStatusChangedTriggerData()
                {
                    ExternalServiceId = "A",
                    Invoice           = new BtcPayInvoice()
                    {
                        Status          = BtcPayInvoice.STATUS_INVALID,
                        ExceptionStatus = "paidLate",
                        CurrentTime     = DateTimeOffset.Now,
                        InvoiceTime     = DateTimeOffset.Now,
                        ExpirationTime  = DateTimeOffset.Now
                    }
                }
            },
                                                  new RecipeTrigger()
            {
                TriggerId         = handler.TriggerId,
                ExternalServiceId = "A",
                DataJson          = JsonConvert.SerializeObject(parameters)
            }));
        }
Esempio n. 7
0
 public void ctor_VirtualisedDataSourceRequired()
 {
     Assert.Throws <ArgumentNullException>(() =>
                                           new IncrementalLoadingCollection <object>(null));
 }
 public static void IsTrue(bool condition, string message = null)
 {
     XAssert.True(condition);
 }
Esempio n. 9
0
        public void InvokeStaticTest()
        {
            Type t = (Type)Invoker.InvokeStatic(typeof(Tester2 <bool>), "Method1", new bool[1]);

            Assert.True(t.Equals(typeof(bool[])));
        }
Esempio n. 10
0
        public void ConversionTest()
        {
            Single     s = 2.5F;
            double     d;
            Conversion conv;

            // primitives
            Assert.True(Conversion.TryGetConversion(typeof(Single), typeof(double), out conv));
            Assert.False(conv.IsExplicit);
            object o = conv.Converter(s);

            d = (double)o;
            Console.WriteLine("{0}: {1}", o.GetType(), d);
            Assert.True(Conversion.TryGetConversion(typeof(double), typeof(Single), out conv));
            Assert.True(conv.IsExplicit);
            o = conv.Converter(d);
            s = (Single)o;
            Console.WriteLine("{0}: {1}", o.GetType(), s);
            Assert.True(Conversion.TryGetConversion(typeof(object), typeof(double), out conv));
            Assert.True(conv.IsExplicit);
            o = conv.Converter(s);
            d = (double)o;
            Console.WriteLine("{0}: {1}", o.GetType(), d);
            Assert.True(Conversion.TryGetConversion(typeof(double), typeof(int), out conv));
            Assert.True(conv.IsExplicit);
            Assert.Throws <ArgumentException>(() =>
            {
                o = conv.Converter(d);
            });

            // enums
            Assert.True(Conversion.TryGetConversion(typeof(string), typeof(BindingFlags), out conv));
            Assert.True(conv.IsExplicit);
            BindingFlags flags = (BindingFlags)conv.Converter("Public");

            // array up-conversion
            Assert.True(Conversion.TryGetConversion(typeof(double), typeof(double[]), out conv));
            o = conv.Converter(d);
            double[] array = (double[])o;
            Console.WriteLine("{0}: {1}", o.GetType(), array[0]);
            Assert.True(Conversion.TryGetConversion(typeof(double[]), typeof(double[, ]), out conv));
            o = conv.Converter(array);
            double[,] array2 = (double[, ])o;
            Console.WriteLine("{0}: {1}", o.GetType(), array2[0, 0]);
            Assert.True(Conversion.TryGetConversion(typeof(System.Reflection.Missing), typeof(double[]), out conv));
            o     = conv.Converter(d);
            array = (double[])o;
            Assert.Empty(array);
            Console.WriteLine("{0}: Length={1}", o.GetType(), array.Length);

            // class up-conversion
            Assert.True(Conversion.TryGetConversion(typeof(PositiveDefiniteMatrix), typeof(Matrix), out conv));
            Assert.True(conv.Converter == null);

            // interface up-conversion
            Assert.True(Conversion.TryGetConversion(typeof(double[]), typeof(IList), out conv));
            Assert.True(conv.Converter == null);

            // array covariance (C# 2.0 specification, sec 20.5.9)
            Assert.True(Conversion.TryGetConversion(typeof(string[]), typeof(IList <string>), out conv));
            Assert.True(conv.Converter == null);
            Assert.True(Conversion.TryGetConversion(typeof(string[]), typeof(IList <object>), out conv));
            Assert.True(conv.Converter == null);
            Assert.False(Conversion.TryGetConversion(typeof(string[, ]), typeof(IList <string>), out conv));
            Assert.False(Conversion.TryGetConversion(typeof(string[, ]), typeof(IList <object>), out conv));

            // array element conversion
            Assert.True(Conversion.TryGetConversion(typeof(object[]), typeof(double[]), out conv));
            Assert.True(conv.IsExplicit);
            object[] oa = new object[2] {
                1.1, 2.2
            };
            o     = conv.Converter(oa);
            array = (double[])o;
            Assert.Equal(oa[0], array[0]);
            Assert.Equal(oa[1], array[1]);
            Console.WriteLine("{0}: {1} {2}", o.GetType(), array[0], array[1]);

            // array down-conversion
            Assert.True(Conversion.TryGetConversion(typeof(double[, ]), typeof(double[]), out conv));
            array2 = new double[, ] {
                { 1.1, 2.2 }
            };
            o     = conv.Converter(array2);
            array = (double[])o;
            Console.WriteLine("{0}: {1} {2}", o.GetType(), array[0], array[1]);

            // custom conversion
            Assert.True(Conversion.TryGetConversion(typeof(Tester), typeof(int), out conv));
            Tester t = new Tester();

            o = conv.Converter(t);
            Console.WriteLine("{0}: {1}", o.GetType(), o);
            Assert.True(Conversion.TryGetConversion(typeof(Tester), typeof(int[]), out conv));
            o = conv.Converter(t);
            Console.WriteLine("{0}: {1}", o.GetType(), o);
            Assert.True(Conversion.TryGetConversion(typeof(int), typeof(Tester), out conv));
            Assert.True(conv.IsExplicit);
            Assert.True(Conversion.TryGetConversion(typeof(int[]), typeof(Tester), out conv));
            Assert.True(conv.IsExplicit);
            Assert.True(Conversion.TryGetConversion(typeof(ImplicitlyConvertibleToTesterDefinesCast), typeof(Tester), out conv));
            Assert.False(conv.IsExplicit);
            Assert.True(Conversion.TryGetConversion(typeof(ImplicitlyConvertibleToTesterCastDefinedOnTester), typeof(Tester), out conv));
            Assert.False(conv.IsExplicit);

            // conversion from null
            Assert.False(Conversion.TryGetConversion(typeof(Nullable), typeof(int), out conv));
            Assert.True(Conversion.TryGetConversion(typeof(Nullable), typeof(int?), out conv));
            Assert.True(Conversion.TryGetConversion(typeof(Nullable), typeof(int[]), out conv));
        }
Esempio n. 11
0
        public void TypeInferenceTest()
        {
            Console.WriteLine("PositiveDefiniteMatrix is assignable to:");
            TestUtils.PrintCollection <Type>(Binding.TypesAssignableFrom(typeof(PositiveDefiniteMatrix)));
            Console.WriteLine();
            MethodInfo method;

            method = typeof(TypeInferenceTests).GetMethod("DelayedSetTo");
            Type formal = method.GetParameters()[0].ParameterType;
            Type actual = typeof(SettableTo <double>);

            TestInferGenericParameters(formal, actual, method, 1);

            actual = typeof(Matrix);
            TestInferGenericParameters(formal, actual, method, 1);

            method = typeof(TypeInferenceTests).GetMethod("Method1", BindingFlags.NonPublic | BindingFlags.Static);
            Type[] args1 = { typeof(Matrix) };
            TestInferGenericParameters(method, args1, 1);
            Console.WriteLine("Inferring {0} from {1}: ", method, typeof(double));
            Assert.Throws <ArgumentException>(() =>
            {
                Invoker.Invoke(method, null, 4.4);
            });

            method = typeof(TypeInferenceTests).GetMethod("DelayedSetTo");
            Type[] args2 = { typeof(Matrix), typeof(Matrix) };
            TestInferGenericParameters(method, args2, 1);

            method = typeof(TypeInferenceTests).GetMethod("DelayedSampleInto");
            Type[] args3 = { typeof(VectorGaussian), typeof(VectorGaussian) };
            TestInferGenericParameters(method, args3, 1);
            VectorGaussian g = new VectorGaussian(1);

            Invoker.Invoke(method, null, g, g);
            args3[0] = typeof(VectorGaussian[]);
            args3[1] = args3[0];
            method   = typeof(TypeInferenceTests).GetMethod("SameSampleableArray");
            TestInferGenericParameters(method, args3, 1);
            VectorGaussian[] ga = { g };
            Assert.Equal(typeof(Vector), (Type)Invoker.Invoke(method, null, ga, ga));

            method = typeof(TypeInferenceTests).GetMethod("SameType");
            Type t = typeof(Matrix);
            int  numMatrixParents = 11;

            args2[0] = t;
            args2[1] = t;
            TestInferGenericParameters(method, args2, numMatrixParents);
            Matrix x = new Matrix(1, 1);

            Assert.Equal(t, (Type)Invoker.Invoke(method, null, x, x));
            Assert.Equal(t, (Type)Invoker.Invoke(method.MakeGenericMethod(t), null, x, x));
            args2[0] = t;
            args2[1] = typeof(Nullable);
            TestInferGenericParameters(method, args2, numMatrixParents);
            Assert.Equal(t, (Type)Invoker.Invoke(method, null, x, null));
            args2[0] = typeof(Nullable);
            args2[1] = t;
            TestInferGenericParameters(method, args2, numMatrixParents);
            Assert.Equal(t, (Type)Invoker.Invoke(method, null, null, x));
            args2[0] = typeof(Nullable);
            args2[1] = typeof(Nullable);
            TestInferGenericParameters(method, args2, 1);
            Assert.Equal(typeof(object), (Type)Invoker.Invoke(method, null, null, null));
            args2[0] = typeof(double);
            args2[1] = typeof(int);
            TestInferGenericParameters(method, args2, 6);
            Assert.Equal(typeof(double), (Type)Invoker.Invoke(method, null, 2.5, 7));


            method   = typeof(TypeInferenceTests).GetMethod("SameArray");
            args2[0] = typeof(Matrix[]);
            args2[1] = typeof(Matrix[]);
            TestInferGenericParameters(method, args2, numMatrixParents);
            Matrix[] a = { x };
            Assert.Equal(t, (Type)Invoker.Invoke(method, null, a, a));

            method = typeof(System.Math).GetMethod("Sqrt");
            Assert.Equal(System.Math.Sqrt(4.0), (double)Invoker.Invoke(method, null, 4.0));
        }
        public void PatronIdUpdatedWhenLibraryCardAccepted()
        {
            scanner.AcceptLibraryCard(somePatronId);

            Assert.Equal(somePatronId, scanner.CurrentPatronId);
        }
        public void ThrowsWhenCheckingInCheckedOutBookWithoutPatronScan()
        {
            scanner.ScanNewMaterial(SomeBarcode, classificationServiceMock);

            Assert.Throws <CheckoutException>(() => scanner.AcceptBarcode(SomeBarcode));
        }
Esempio n. 14
0
        public void RangeFailsIfTimeIdentifiersAreNotAlike()
        {
            var calendarQuarterIdentifiers = new[]
            {
                CalendarYearQ1,
                CalendarYearQ2,
                CalendarYearQ3,
                CalendarYearQ4
            };

            var monthIdentifiers = new[]
            {
                January,
                February,
                March,
                April,
                May,
                June,
                July,
                August,
                September,
                October,
                November,
                December
            };

            var weekIdentifiers = new[]
            {
                Week1,
                Week2,
                Week3,
                Week4,
                Week5,
                Week6,
                Week7,
                Week8,
                Week9,
                Week10,
                Week11,
                Week12,
                Week13,
                Week14,
                Week15,
                Week16,
                Week17,
                Week18,
                Week19,
                Week20,
                Week21,
                Week22,
                Week23,
                Week24,
                Week25,
                Week26,
                Week27,
                Week28,
                Week29,
                Week30,
                Week31,
                Week32,
                Week33,
                Week34,
                Week35,
                Week36,
                Week37,
                Week38,
                Week39,
                Week40,
                Week41,
                Week42,
                Week43,
                Week44,
                Week45,
                Week46,
                Week47,
                Week48,
                Week49,
                Week50,
                Week51,
                Week52
            };

            var termIdentifiers = new[]
            {
                AutumnTerm,
                AutumnSpringTerm,
                SpringTerm,
                SummerTerm
            };

            var financialYearPartIdentifiers = new[]
            {
                FinancialYearPart1,
                FinancialYearPart2
            };

            foreach (var identifier in _allTimeIdentifiers.Except(calendarQuarterIdentifiers))
            {
                Assert.Throws <ArgumentException>(() =>
                                                  TimePeriodUtil.Range(new TimePeriodQuery(2018, CalendarYearQ1, 2019, identifier)));
            }

            foreach (var identifier in _allTimeIdentifiers.Except(monthIdentifiers))
            {
                Assert.Throws <ArgumentException>(() =>
                                                  TimePeriodUtil.Range(new TimePeriodQuery(2018, January, 2019, identifier)));
            }

            foreach (var identifier in _allTimeIdentifiers.Except(weekIdentifiers))
            {
                Assert.Throws <ArgumentException>(() =>
                                                  TimePeriodUtil.Range(new TimePeriodQuery(2018, Week1, 2019, identifier)));
            }

            foreach (var identifier in _allTimeIdentifiers.Except(termIdentifiers))
            {
                Assert.Throws <ArgumentException>(() =>
                                                  TimePeriodUtil.Range(new TimePeriodQuery(2018, AutumnTerm, 2019, identifier)));
            }

            foreach (var identifier in _allTimeIdentifiers.Except(financialYearPartIdentifiers))
            {
                Assert.Throws <ArgumentException>(() =>
                                                  TimePeriodUtil.Range(new TimePeriodQuery(2018, FinancialYearPart1, 2019, identifier)));
            }

            Assert.Throws <ArgumentException>(() =>
                                              TimePeriodUtil.Range(new TimePeriodQuery(2018, CalendarYear, 2019, AcademicYear)));

            Assert.Throws <ArgumentException>(() =>
                                              TimePeriodUtil.Range(new TimePeriodQuery(2018, CalendarYear, 2019, TaxYear)));

            Assert.Throws <ArgumentException>(() =>
                                              TimePeriodUtil.Range(new TimePeriodQuery(2018, CalendarYear, 2019, FinancialYear)));

            Assert.Throws <ArgumentException>(() =>
                                              TimePeriodUtil.Range(new TimePeriodQuery(2018, CalendarYear, 2019, ReportingYear)));
        }
Esempio n. 15
0
 public void RangeFailsIfStartYearIsAfterEndYear()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
                                                 TimePeriodUtil.Range(new TimePeriodQuery(2019, CalendarYear, 2018, CalendarYear)));
 }
        public void privateMethod_test_success()
        {
            var result = _calculatorFixture.CalcPrivate.Invoke("AddThenSubtract", 3, 4) as int?;

            Assert.True(result == 6);
        }
Esempio n. 17
0
 public void NullSettingsThrowsIfWriteOperationMethodsAreInvoked(Assert.ThrowsDelegate throwsDelegate, string methodName)
 {
     // Act and Assert
     ExceptionAssert.Throws<InvalidOperationException>(throwsDelegate,
         String.Format("\"{0}\" cannot be called on a NullSettings. This may be caused on account of insufficient permissions to read or write to \"%AppData%\\NuGet\\NuGet.config\".", methodName));
 }
 public void test_add_success()
 {
     Assert.True(_calculatorFixture.Calc.Add(3, 4) == 7, "Cal Add result is 7. ");
 }
Esempio n. 19
0
 public static void IsFalse(bool condition)
 {
     XAssert.False(condition);
 }
 public void test_add_fail()
 {
     Assert.False(_calculatorFixture.Calc.Add(3, 4) == 10, "Cal Add result isn't 10. ");
 }
Esempio n. 21
0
        public void HasMoreItems_IsTrueByDefault()
        {
            var collection = new IncrementalLoadingCollection <object>(Mock.Create <IVirtualisedDataSource <object> >());

            Assert.Equal(true, collection.HasMoreItems);
        }
 public void test_subtract_success()
 {
     Assert.True(_calculatorFixture.Calc.Subtract(3, 4) == -1, "Cal subtract result is -1. ");
 }
Esempio n. 23
0
 public static void AreNotEqual(object expected, object actual, string message = null)
 {
     XAssert.NotEqual(expected, actual);
 }
 public void test_subtract_fail()
 {
     Assert.False(_calculatorFixture.Calc.Subtract(3, 4) == -10, "Cal subtract result isnot  -10. ");
 }
Esempio n. 25
0
 public static void IsFalse(bool condition, string message = null, params object[] args)
 {
     XAssert.False(condition);
 }
        public void test_subtract_generic(int x, int y, int result, bool expected)
        {
            var check = _calculatorFixture.Calc.Subtract(x, y) == result;

            Assert.Equal(check, expected);
        }
Esempio n. 27
0
 public static void AreSame(object expected, object actual)
 {
     XAssert.Same(expected, actual);
 }
        public void test_subtract_generic_using_share_data_in_custom_attribute(int x, int y, int result, bool expected)
        {
            var check = _calculatorFixture.Calc.Subtract(x, y) == result;

            Assert.Equal(check, expected);
        }
Esempio n. 29
0
 public static void Contains <T>(IEnumerable <T> values, T expected)
 {
     XAssert.Contains(expected, values);
 }
Esempio n. 30
0
 public void CreateShouldThrowExceptionIfInvalidBirthNumberIsUsed()
 {
     Assert.Throws <ArgumentException>(() => NorwegianBirthNumber.Create("19089328342"));
 }
 public static void AreEqual(double expected, double actual, double r)
 {
     XAssert.Equal(expected, actual, 5); // hack
 }
Esempio n. 32
0
        public void IdentifyCorrectTokenTypes()
        {
            var expectedTokens = new SyntaxKind[]
            {
                SyntaxKind.IfKeyword,
                SyntaxKind.Identifier,
                SyntaxKind.EqualityOperator,
                SyntaxKind.String,
                SyntaxKind.ThenKeyword,
                SyntaxKind.Identifier,
                SyntaxKind.AssignmentOperator,
                SyntaxKind.Identifier,
                SyntaxKind.PlusOperator,
                SyntaxKind.Identifier,
                SyntaxKind.ElseIfKeyword,
                SyntaxKind.Identifier,
                SyntaxKind.EqualityOperator,
                SyntaxKind.String,
                SyntaxKind.ThenKeyword,
                SyntaxKind.Identifier,
                SyntaxKind.AssignmentOperator,
                SyntaxKind.Identifier,
                SyntaxKind.MinusOperator,
                SyntaxKind.Identifier,
                SyntaxKind.Identifier,
                SyntaxKind.Colon,
                SyntaxKind.Identifier,
                SyntaxKind.OpenParen,
                SyntaxKind.Identifier,
                SyntaxKind.CloseParen,
                SyntaxKind.Semicolon,
                SyntaxKind.Identifier,
                SyntaxKind.Dot,
                SyntaxKind.Identifier,
                SyntaxKind.Colon,
                SyntaxKind.Identifier,
                SyntaxKind.OpenParen,
                SyntaxKind.Identifier,
                SyntaxKind.Dot,
                SyntaxKind.Identifier,
                SyntaxKind.MinusOperator,
                SyntaxKind.Number,
                SyntaxKind.Comma,
                SyntaxKind.Identifier,
                SyntaxKind.Dot,
                SyntaxKind.Identifier,
                SyntaxKind.CloseParen,
                SyntaxKind.Colon,
                SyntaxKind.Identifier,
                SyntaxKind.OpenParen,
                SyntaxKind.Identifier,
                SyntaxKind.CloseParen,
                SyntaxKind.ElseIfKeyword,
                SyntaxKind.Identifier,
                SyntaxKind.EqualityOperator,
                SyntaxKind.String,
                SyntaxKind.ThenKeyword,
                SyntaxKind.Identifier,
                SyntaxKind.AssignmentOperator,
                SyntaxKind.Identifier,
                SyntaxKind.MultiplyOperator,
                SyntaxKind.Identifier,
                SyntaxKind.ElseIfKeyword,
                SyntaxKind.Identifier,
                SyntaxKind.EqualityOperator,
                SyntaxKind.String,
                SyntaxKind.ThenKeyword,
                SyntaxKind.Identifier,
                SyntaxKind.Dot,
                SyntaxKind.Identifier,
                SyntaxKind.Colon,
                SyntaxKind.Identifier,
                SyntaxKind.OpenParen,
                SyntaxKind.Identifier,
                SyntaxKind.Dot,
                SyntaxKind.Identifier,
                SyntaxKind.MinusOperator,
                SyntaxKind.Number,
                SyntaxKind.Comma,
                SyntaxKind.Identifier,
                SyntaxKind.Dot,
                SyntaxKind.Identifier,
                SyntaxKind.CloseParen,
                SyntaxKind.Colon,
                SyntaxKind.Identifier,
                SyntaxKind.OpenParen,
                SyntaxKind.Identifier,
                SyntaxKind.CloseParen,
                SyntaxKind.Identifier,
                SyntaxKind.AssignmentOperator,
                SyntaxKind.Identifier,
                SyntaxKind.DivideOperator,
                SyntaxKind.Identifier,
                SyntaxKind.ElseKeyword,
                SyntaxKind.Identifier,
                SyntaxKind.OpenParen,
                SyntaxKind.String,
                SyntaxKind.CloseParen,
                SyntaxKind.EndKeyword,
                SyntaxKind.Identifier,
                SyntaxKind.AssignmentOperator,
                SyntaxKind.Number,
                SyntaxKind.EndOfFile,
            };

            TextReader   testProgramStream = File.OpenText(@"CorrectSampleLuaFiles\if.lua");
            List <Token> tokenList         = Lexer.Tokenize(testProgramStream);
            int          tokenIndex        = 0;

            for (int i = 0; i < expectedTokens.Length; i++)
            {
                Assert.Equal(expectedTokens[i], tokenList[tokenIndex++].Kind);
            }
        }
Esempio n. 33
0
        private static void AssertInvalidOperationExceptionIsThrown(Assert.ThrowsDelegate action)
        {
            var ex = Assert.Throws<InvalidOperationException>(action);

            Assert.Equal(
                ExceptionMessages.EnsureExtensions_InvalidOperationException.Inject(ParamName),
                ex.Message);
        }
        public static Exception ShouldBeThrownBy(this Type exceptionType,
#if PORTABLE40
			Assert.ThrowsDelegate code