public void GetGoodsReceiptMessage_whenDirectPaymentVendorButNonOfVendorRulesMatch_shouldUseCommonPaymentRules() { // Arrange SetupCommonPaymentRule(); var dbRules = new List <CompiledRule <TestRule> >(); var directPaymentVendorId = Guid.NewGuid(); var directVendorSplit = (decimal)50.00; var commonRuleSplit = (decimal)100.00; var totalAmount = 1000; var expected = commonRuleSplit * totalAmount / 100; const string region = "China"; var testRule = new TestRule { BudgetRegion = region, DirectPaymentVendorId = directPaymentVendorId, TotalCostAmount = totalAmount }; const string commonPaymentRuleRegion = "Any other region"; dbRules.Add(GetBudgetRegionCriterion(commonPaymentRuleRegion, directVendorSplit)); dbRules.Add(GetBudgetRegionCriterion(region, commonRuleSplit)); // Act decimal amount; Service.TryMatchRule(dbRules, testRule, _matchFunc, out amount); // Assert amount.Should().Be(expected); }
public virtual Statement apply(Statement @base, Description description) { lookUpContainerSpecifics(); TestRule containerSpecificRule = containerSpecifics.getTestRule(description.TestClass); return(containerSpecificRule.apply(@base, description)); }
public void Cannot_Set_ErrorResourceType_After_Setting_ErrorMessage() { var rule = new TestRule(); rule.ErrorMessage = "Some error message"; Assert.Throws<InvalidOperationException>(delegate { rule.ErrorMessageResourceType = typeof(TestResources); }); }
public void Conditions_ReturnsEmpty_ByDefault() { // Arrange // Act TestRule sut = CreateSut(); // Assert //sut.GetConditions().Count().ShouldEqual(0); }
public void Priority_ReturnsInteger_WhenCalled() { // Arrange CellInformation info = CreateCellInformation(); TestRule sut = CreateSut(); // Act sut.Apply(info); // Assert sut.Priority.ShouldEqual(1); }
public void Initialize_AddsConditions_WhenCalled() { // Arrange ICellInformation info = CreateCellInformation(); TestRule sut = CreateSut(); // Act sut.Initialize(info); // Assert //sut.GetConditions().Count().ShouldEqual(2); }
private TestRule PopulateRuleProperties(string id, string name) { // This helper exhaustively sets an arbitrary guid string value to every // rule property (as well as setting the provided id and name). This ensures // that every rule instance has unique data associated with it outside the // id and name (and therefore ensures these unique values are never considered // when comparing rule instances via the SkimmerIdComparer). var rule = new TestRule() { Id = id, Name = name }; rule.DefaultConfiguration = new ReportingConfiguration(); rule.DefaultConfiguration.SetProperty <string>(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); rule.DeprecatedGuids = new string[] { Guid.NewGuid().ToString() }; rule.DeprecatedIds = new string[] { Guid.NewGuid().ToString() }; rule.DeprecatedNames = new string[] { Guid.NewGuid().ToString() }; rule.FullDescription = new MultiformatMessageString { Text = Guid.NewGuid().ToString() }; rule.Guid = Guid.NewGuid().ToString(); rule.Help = new MultiformatMessageString { Text = Guid.NewGuid().ToString() }; rule.HelpUri = new Uri(Guid.NewGuid().ToString(), UriKind.RelativeOrAbsolute); rule.MessageStrings = new Dictionary <string, MultiformatMessageString> { [Guid.NewGuid().ToString()] = new MultiformatMessageString { Text = Guid.NewGuid().ToString() } }; rule.SetProperty <string>(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); rule.Relationships = new[] { new ReportingDescriptorRelationship { Description = new Message { Text = Guid.NewGuid().ToString() } } }; rule.ShortDescription = new MultiformatMessageString { Text = Guid.NewGuid().ToString() }; return(rule); }
public void Initialize_CallsInitialize_WhenCalled() { // Arrange ICellInformation info = CreateCellInformation(); TestRule sut = CreateSut(); // Act sut.Initialize(info); // Assert //sut.WasCalledInitialize.ShouldBeTrue(); }
public void Apply_CallsApply_WhenCalled() { // Arrange ICellInformation info = CreateCellInformation(); TestRule sut = CreateSut(); // Act sut.Apply(info); // Assert //sut.WasCalledApply.ShouldBeTrue(); }
public void SkimmerBase_GetsPlainTextMessageStringsFromResources() { var skimmer = new TestRule(); skimmer.MessageStrings.Count.Should().Be(new TestRule().MessageStrings.Count()); skimmer.MessageStrings["Failed"].Text.Should().Be(SkimmerBaseTestResources.TEST1001_Failed); skimmer.MessageStrings["Note"].Text.Should().Be(SkimmerBaseTestResources.TEST1001_Note); skimmer.MessageStrings["Pass"].Text.Should().Be(SkimmerBaseTestResources.TEST1001_Pass); skimmer.MessageStrings["Open"].Text.Should().Be(SkimmerBaseTestResources.TEST1001_Open); skimmer.MessageStrings["Review"].Text.Should().Be(SkimmerBaseTestResources.TEST1001_Review); skimmer.MessageStrings["Information"].Text.Should().Be(SkimmerBaseTestResources.TEST1001_Information); }
public void BuildRule_GeneratesExpectedMarkdown() { var resourceExtractor = new ResourceExtractor(this.GetType()); var sb = new StringBuilder(); var testRule = new TestRule(); var command = new ExportRuleDocumentationCommand(); command.BuildRule(testRule, sb); string expectedMarkdown = resourceExtractor.GetResourceText("Test.md"); sb.ToString().Should().Be(expectedMarkdown); }
public void SkimmerIdComparer_HandlesNullCasesProperly() { SkimmerIdComparer <TestAnalysisContext> .Instance.Compare(null, null).Should().Be(0); var skimmer = new TestRule(); int leftIsNull = SkimmerIdComparer <TestAnalysisContext> .Instance.Compare(null, skimmer); int rightIsNull = SkimmerIdComparer <TestAnalysisContext> .Instance.Compare(skimmer, null); leftIsNull.Should().NotBe(0); rightIsNull.Should().NotBe(0); leftIsNull.Should().NotBe(rightIsNull); }
public void ClearConditions_ClearsCondintions_WhenCalled() { // Arrange CellInformation info = CreateCellInformation(); TestRule sut = CreateSut(); sut.Initialize(info); // Act sut.ClearConditions(); // Assert sut.GetConditions().Count().ShouldEqual(0); }
public void SkimmerIdComparer_ComparesIdAndName() { var failedTestCases = new List <string>(); foreach (SkimmerIdComparerTestCase testCase in s_skimmerIdComparerTestCases) { TestRule leftRule = PopulateRuleProperties(id: testCase.LeftId, name: testCase.LeftName); TestRule rightRule = PopulateRuleProperties(id: testCase.RightId, name: testCase.RightName); int comparison = SkimmerIdComparer <TestAnalysisContext> .Instance.Compare(leftRule, rightRule); switch (testCase.ExpectedResult) { case Equivalence.Equal: { if (comparison != 0) { failedTestCases.Add(testCase.Title); } break; } case Equivalence.LessThan: { if (comparison >= 0) { failedTestCases.Add(testCase.Title); } break; } case Equivalence.GreaterThan: { if (comparison <= 0) { failedTestCases.Add(testCase.Title); } break; } } } failedTestCases.Should().BeEmpty(); }
private void btnTestSummaryWithRule_Click(object sender, EventArgs e) { List <TestFrmSummary> sources = new List <TestFrmSummary>(); TestFrmSummary source11 = new TestFrmSummary() { ID = 1, CODE = "C1234567", DOC_STATE = 1, NUMBER = 5, PRICE = 10 }; TestFrmSummary source11Ext = new TestFrmSummary() { ID = 6, CODE = "C123456", DOC_STATE = 1, NUMBER = 100, PRICE = 100 }; TestFrmSummary source12 = new TestFrmSummary() { ID = 2, CODE = "C1", DOC_STATE = 2, NUMBER = 6, PRICE = 20 }; TestFrmSummary source13 = new TestFrmSummary() { ID = 3, CODE = "C1", DOC_STATE = 3, NUMBER = 7, PRICE = 30 }; TestFrmSummary source21 = new TestFrmSummary() { ID = 4, CODE = "C2", DOC_STATE = 1, NUMBER = 5, PRICE = 10 }; TestFrmSummary source22 = new TestFrmSummary() { ID = 5, CODE = "C2", DOC_STATE = 2, NUMBER = 6, PRICE = 20 }; sources.Add(source11); sources.Add(source12); sources.Add(source13); sources.Add(source21); sources.Add(source22); sources.Add(source11Ext); TestRule rule = new TestRule(); MB.WinClientDefault.Common.FrmSummay frm = new MB.WinClientDefault.Common.FrmSummay(rule, sources); //MB.WinClientDefault.Common.FrmSummay frm = new MB.WinClientDefault.Common.FrmSummay("FrmSummaryTest", sources); frm.ShowDialog(); }
public void ErrorMessageOrResourceString_Returns_ErrorMessage_When_Set() { var rule = new TestRule { ErrorMessage = "My error message" }; Assert.Equal("My error message", rule.ErrorMessageOrResourceString); }
public void TryExtractProperties() { var r = new TestRule(); var condition = r.Condition; }
private TestRule CreateSut() { var testRule = new TestRule(); return(testRule); }
public void Can_Set_ErrorMessage() { var rule = new TestRule(); rule.ErrorMessage = "Some error message"; }
public void Can_Set_ErrorResourceType_And_Name() { var rule = new TestRule(); rule.ErrorMessageResourceType = typeof (TestResources); rule.ErrorMessageResourceName = "Anything"; }
public void ErrorMessageOrResourceString_Returns_Null_When_No_Values_Were_Set() { var rule = new TestRule(); Assert.Null(rule.ErrorMessageOrResourceString); }
public void ErrorMessageOrResourceString_Returns_Resource_String_When_Configured() { var rule = new TestRule { ErrorMessageResourceType = typeof(TestResources), ErrorMessageResourceName = "SomeResource" }; Assert.Equal("This is a resource string", rule.ErrorMessageOrResourceString); }