Beispiel #1
0
 static void Using()
 {
     using (IDisposable id = new Test())
     {
         Console.WriteLine(id);
     }
 }
 public override void Visit(Test.AliquotOrder aliquotOrder)
 {
     if (aliquotOrder.TestOrderCollection.Exists(this.m_TestOrder.TestOrderId) == true)
     {
         this.m_TestOrderLeftSideIsRemoved = false;
     }
 }
 private void visit(Test test, IHierarchyVisitor visitor)
 {
     if (TestFilter(test))
     {
         visitor.Test(test);
     }
 }
Beispiel #4
0
        public static void Main3()
        {
            Test t1 = new Test()
            {
                value1 = "qoo1",
                value2 = "test2"
            };
            Test t2 = new Test()
            {
                value1 = "T2",
                value2 = "Q2",
                B1 = new byte[] { 123, 58, 69, 77, 99, 255 },
                B2 = new byte[] { 33, 44, 55, 66, 77, 88, 99, 0 }
            };
            string jsonT1 = JsonConvert.SerializeObject(t1);
            Test t11 = JsonConvert.DeserializeObject<Test>(jsonT1);
            Console.WriteLine("t1 serialize:" + jsonT1);

            string jsonT2 = JsonConvert.SerializeObject(t2);//物件內的陣列元素會被轉換成Base64字串

            string b1 = Convert.ToBase64String(t2.B1);//
            byte[] b11 = Convert.FromBase64String(b1);
            t11 = JsonConvert.DeserializeObject<Test>(jsonT2);
            Console.WriteLine("t2 serialize:" + jsonT2);
            string filePath = @"C:\MyDirectory\My.File.bat";
            string data = System.IO.Path.GetDirectoryName(filePath);
            bool isExist = Directory.Exists(data);
            //System.Web.Routing.Route router = new System.Web.Routing.Route("http://www.google.com/",)
            //IRouteHandler r ;
        }
        public void Test03TestOnDelete()
        {
            dbCreated = true;
            var test = new Test
            {
                Name = "Test",
                ClientApplication = new ClientApplication
                                        {
                                            Name = "Test app",
                                            Key = Guid.NewGuid(),
                                            IsActive = true
                                        },
                IsActive = true,
                Key = "Test"
            };
            dbContext.Tests.Add(test);

            // save and refresh context
            dbContext.SaveChanges();
            dbContext.Dispose();
            var contextFactory = container.GetInstance<IDbContextFactory<HealthCheckDbContext>>();
            dbContext = contextFactory.Build();

            var beforeDelete = dbContext.Tests.Count();
            Assert.IsTrue(beforeDelete > 0, "No tests after save.");

            var test2 = dbContext.Tests.First(g => g.Id == test.Id); // reload from new context
            dbContext.Tests.Remove(test2);
            dbContext.SaveChanges();

            int afterDelete = dbContext.Tests.Count();

            Assert.AreEqual(beforeDelete - 1, afterDelete, "Tests should be deleted.");
        }
Beispiel #6
0
 public Question GetNextQuestion(Test test, Question prevQuestion, ITestLogic logic)
 {
     this.logic = logic;
     int qId = logic.GetQuestionId(test, prevQuestion, uow);
     Question q = uow.Questions.GetById(qId);
     return q;
 }
 public OutlineTreeBuilder(Test test, FixtureLibrary library, IOutlineConfigurer configurer)
 {
     var workspace = test.GetWorkspace();
     _library = library.Filter(workspace.CreateFixtureFilter().Matches);
     _test = test;
     _configurer = configurer;
 }
Beispiel #8
0
        /// <summary>
        /// проверка ответов пользователя
        /// </summary>
        /// <param name="OriginalTest">оригинальный тест</param>
        /// <returns></returns>
        public ClientResult Verify(ref Test OriginalTest)
        {
            ClientResult res = new ClientResult();

            int ClientBalls = 0;

            foreach (ClientQuestion cq in this.Questions)
            {
                try
                {
                    QuestionBase qb = FindOriginalQuestion(cq, ref OriginalTest);
                    cq.Ball = qb.Verify(cq);
                    cq.MaxBall = qb.MaxBall;
                    cq.MinBall = qb.MinBall;
                    ClientBalls += cq.Ball;
                }
                catch
                {
                    throw new ArgumentException();
                }
            }

            res = new ClientResult(OriginalTest.MaxQuestionsBall, ClientBalls,OriginalTest.Settings);
            return res;
        }
        public AccessionOrderDataSheetDataV2(Test.AccessionOrder accessionOrder, ClientOrder.Model.ClientOrderCollection clientOrderCollection, Domain.OrderCommentLogCollection orderCommentLogCollection)
        {
            this.m_AccessionOrderDataSheetDataAccessionOrder = new AccessionOrderDataSheetDataAccessionOrder(accessionOrder, clientOrderCollection);
            this.m_AccessionOrderDataSheetDataClientOrders = new List<AccessionOrderDataSheetDataClientOrder>();
            this.m_AccessionOrderDataSheetDataSpecimenOrders = new List<AccessionOrderDataSheetDataSpecimenOrder>();
            this.m_AccessionOrderDataSheetDataCommentLogs = new List<AccessionOrderDataSheetDataCommentLog>();

            foreach (Business.ClientOrder.Model.ClientOrder clientOrder in clientOrderCollection)
            {
                AccessionOrderDataSheetDataClientOrder accessionOrderDataSheetDataClientOrder = new AccessionOrderDataSheetDataClientOrder(clientOrder);
                this.m_AccessionOrderDataSheetDataClientOrders.Add(accessionOrderDataSheetDataClientOrder);
            }

            foreach (Specimen.Model.SpecimenOrder specimenOrder in accessionOrder.SpecimenOrderCollection)
            {
                AccessionOrderDataSheetDataSpecimenOrder accessionOrderDataSheetDataSpecimenOrder = new AccessionOrderDataSheetDataSpecimenOrder(specimenOrder, clientOrderCollection);
                this.m_AccessionOrderDataSheetDataSpecimenOrders.Add(accessionOrderDataSheetDataSpecimenOrder);
            }

            foreach (Domain.OrderCommentLog orderCommentLog in orderCommentLogCollection)
            {
                AccessionOrderDataSheetDataCommentLog accessionOrderDataSheetDataCommentLog = new AccessionOrderDataSheetDataCommentLog(orderCommentLog);
                this.m_AccessionOrderDataSheetDataCommentLogs.Add(accessionOrderDataSheetDataCommentLog);
            }
        }
Beispiel #10
0
 private void uložitButton_Click(object sender, RoutedEventArgs e)
 {
     if (názevTextBox.Text != "" && popisTextBox.Text != "" && splnitDoDatePicker.SelectedDate != null)
     {
         int skupina;
         switch (skupinaCombobox.SelectedIndex)
         {
             case 0:
                 skupina = 1;
                 break;
             case 1:
                 skupina = 2;
                 break;
             default:
                 skupina = 0;
                 break;
         }
         Test = new Test(názevTextBox.Text, popisTextBox.Text, (předměty)Enum.Parse(typeof(předměty), ((ComboBoxItem)předmětComboBox.SelectedItem).Content.ToString()), skupina, (DateTime)splnitDoDatePicker.SelectedDate);
         this.Close();
     }
     else
     {
         MessageBox.Show("Některá z požadovaných polí nejsou vyplněna!", "Chyba", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
	// Start a new test.
	public virtual void StartTest(Test test, bool isSuite)
			{
				if(!isSuite)
				{
					++numTestsRun;
				}
			}
Beispiel #12
0
 public void SomethingClass()
 {
     var test = new Test();
     var mTest = test.ToMaybe();
     Assert.AreEqual(true, mTest.IsSomething);
     Assert.AreEqual(false, mTest.IsNothing);
 }
Beispiel #13
0
 public TestFailure(Test failedTest, Exception thrownException)
 {
   base.\u002Ector();
   TestFailure testFailure = this;
   this.fFailedTest = failedTest;
   this.fThrownException = thrownException;
 }
 public void TestBasicValidationAttributeGood()
 {
     Test test = new Test();
     test.Property = "Testregexgood";
     Validator.Core.Validator v = new Core.Validator();
     Assert.That((Boolean)v.ValidateObject(test), Is.True);
 }
        public void Invoke_MarshalObjectByRef_FourArg()
        {
            using (var context = AppDomainContext.Create())
            {
                var actual = new Test();
                RemoteAction.Invoke(
                    context.Domain,
                    actual,
                    (short)11,
                    new Double?(12.0),
                    new Composite() { Value = 13 },
                    (test, value2, value3, value4) =>
                    {
                        test.Value1 = 10;
                        test.Value2 = value2;
                        test.Value3 = value3;
                        test.Value4 = value4;
                    });

                Assert.IsNotNull(actual);
                Assert.AreEqual(10, actual.Value1);
                Assert.AreEqual(11, actual.Value2);
                Assert.AreEqual(12.0, actual.Value3);

                Assert.IsNotNull(actual.Value4);
                Assert.AreEqual(13, actual.Value4.Value);
            }
        }
        private static IList GetSourcesFor(MethodInfo method, Test parent)
        {
            ArrayList sources = new ArrayList();
            TestFixture parentSuite = parent as TestFixture;

            foreach (Attribute sourceAttr in Reflect.GetAttributes(method, NUnitFramework.TestCaseSourceAttribute, false))
            {
                Type sourceType = Reflect.GetPropertyValue(sourceAttr, SourceTypeProperty) as Type;
                string sourceName = Reflect.GetPropertyValue(sourceAttr, SourceNameProperty) as string;

                if (sourceType == null)
                {
                    if (parentSuite != null)
                        sources.Add(new ProviderReference(parentSuite.FixtureType, parentSuite.arguments, sourceName));
                    else
                        sources.Add(new ProviderReference(method.ReflectedType, sourceName));
                }
                else
                {
                    sources.Add(new ProviderReference(sourceType, sourceName));
                }

            }
            return sources;
        }
		public void MapObjectToObject()
		{
			var s1 = new Test { ID = 1, Value = "123" };
			var s2 = new Test();

			Map.ObjectToObject(s1, s2, null);
		}
Beispiel #18
0
        public static Test CreateTest(INode element, ITestPartCollection parts)
        {
            var test = new Test(element["name"], parts);

            readLifecycle(test, element);
            return test;
        }
 public override void Visit(Test.AliquotOrder aliquotOrder)
 {
     if (aliquotOrder.SlideOrderCollection.Exists(this.m_SlideOrder.SlideOrderId) == true)
     {
         aliquotOrder.SlideOrderCollection.Remove(this.m_SlideOrder.SlideOrderId);
     }
 }
 public TestScreenCloser(Test test, ITestStateManager stateManager, IMessageCreator messageBox, IEditTestController controller)
 {
     _test = test;
     _stateManager = stateManager;
     _messageBox = messageBox;
     _controller = controller;
 }
Beispiel #21
0
        public void add_comment()
        {
            var test = new Test("some test");

            test.AddComment("some text");
            test.Parts[0].ShouldBeOfType<Comment>().Text.ShouldEqual("some text");
        }
        public OutlineNode BuildNode(Test test, IOutlineController controller)
        {
            var builder = this.builder(controller, test);

            _topNode = builder.Build();
            return _topNode;
        }
Beispiel #23
0
        public DemoForm()
        {
            this.InitializeComponent();

            // Generate some test / demo objects
            Test testObj = new Test();
            testObj.IPropWithAVeryLongName = 42;
            testObj.SomeString = "Blubdiwupp";
            testObj.SomeFloat = (float)Math.PI;
            testObj.SomeByte = 128;
            testObj.Subclass = new Test2(42);
            testObj.stringListField = new List<string>() { "hallo", "welt" };
            Test testObj2 = new Test();
            testObj2.IPropWithAVeryLongName = 447;
            testObj2.SomeString = "Kratatazong";
            testObj2.Subclass = new Test2();
            testObj2.enumField2 = EnumTest.Three;

            // Case A: Singleselect
            this.propertyGrid1.SelectObject(testObj);
            // Case B: Multiselect
            //this.propertyGrid1.SelectObjects(new object[] { testObj, testObj2 });
            // Case C: Select this very form
            //this.propertyGrid1.SelectObject(this);
        }
Beispiel #24
0
 public void Adding_tags_should_add_to_existing_tags()
 {
     Test test = new Test("test");
     List<string> tags = new List<string> { "tagged", "another" };
     tags.ForEach(x => test.AddTags(x));
     tags.ForEach(tag => test.GetTags().AllTags.Contains(tag));
 }
 public override void Visit(Test.PanelOrder panelOrder)
 {
     if (panelOrder.TestOrderCollection.Exists(this.m_TestOrder.TestOrderId) == true)
     {
         this.m_TestOrderRightSideIsRemoved = false;
     }
 }
        /// <summary>
        /// Construct one or more TestMethods from a given MethodInfo,
        /// using available parameter data.
        /// </summary>
        /// <param name="method">The MethodInfo for which tests are to be constructed.</param>
        /// <param name="suite">The suite to which the tests will be added.</param>
        /// <returns>One or more TestMethods</returns>
        public IEnumerable<TestMethod> BuildFrom(IMethodInfo method, Test suite)
        {
            List<TestMethod> tests = new List<TestMethod>();
            
            IParameterInfo[] parameters = method.GetParameters();

            if (parameters.Length > 0)
            {
                IEnumerable[] sources = new IEnumerable[parameters.Length];

                try
                {
                    for (int i = 0; i < parameters.Length; i++)
                        sources[i] = _dataProvider.GetDataFor(parameters[i]);
                }
                catch (InvalidDataSourceException ex)
                {
                    var parms = new TestCaseParameters();
                    parms.RunState = RunState.NotRunnable;
                    parms.Properties.Set(PropertyNames.SkipReason, ex.Message);
                    tests.Add(_builder.BuildTestMethod(method, suite, parms));
                    return tests;
                }

                foreach (var parms in _strategy.GetTestCases(sources))
                    tests.Add(_builder.BuildTestMethod(method, suite, (TestCaseParameters)parms));
            }

            return tests;
        }
Beispiel #27
0
        /// <summary>
        /// Construct a WorkItem for a particular test.
        /// </summary>
        /// <param name="test">The test that the WorkItem will run</param>
        public WorkItem(Test test, FinallyDelegate finallyDelegate)
        {
            _test = test;
            testResult = test.MakeTestResult();
            _state = WorkItemState.Ready;
	    finD = finallyDelegate;
        }
        public void TestClassMap()
        {
            // this test passes normally when the Test class is automapped
            // uncomment all or parts of the class map initialization code to test
            // the exceptions thrown for each non-compliant field or property

            if (firstTime) {
                BsonClassMap.RegisterClassMap<Test>(cm => {
                    cm.AutoMap();
                    // cm.MapField("literal");
                    // cm.MapField("readOnly");
                    // cm.MapField("notfound");
                    // cm.MapProperty("GetOnly");
                    // cm.MapProperty("SetOnly");
                    // cm.MapProperty("notfound");
                    // cm.MapMember(null);
                });
                firstTime = false;
            }

            var test = new Test("x") { SetOnly = "y" };
            var json = test.ToJson();
            var expected = "{ '_id' : { '$oid' : '000000000000000000000000' } }".Replace("'", "\"");
            // Assert.AreEqual(expected, json);

            var bson = test.ToBson();
            var rehydrated = BsonSerializer.Deserialize<Test>(bson);
            Assert.IsTrue(bson.SequenceEqual(rehydrated.ToBson()));
        }
Beispiel #29
0
 /// <summary>
 /// Construct a WorkItem for a particular test.
 /// </summary>
 /// <param name="test">The test that the WorkItem will run</param>
 /// <param name="context">The TestExecutionContext in which it will run</param>
 public WorkItem(Test test, TestExecutionContext context)
 {
     _test = test;
     _testResult = test.MakeTestResult();
     _state = WorkItemState.Ready;
     _context = context;
 }
        public void GlassRead_ClassReadIntoItem()
        {

            Item item = _db.GetItem("/sitecore/content/ItemExtensions/Test");

            //Assign
            Test testItem = new Test();
            testItem.DateTime = new DateTime(2011, 05, 06, 15, 16, 17);
            testItem.SingleLineText = "Awesome content";
                
            //Act
            using (new SecurityDisabler())
            {
                item.Editing.BeginEdit();

                item.GlassRead(testItem);

                //Assert

                Assert.AreEqual("Awesome content", item["SingleLineText"]);
                Assert.AreEqual("20110506T151617", item["DateTime"]);


                item.Editing.CancelEdit();


            }





        }