示例#1
0
 public void CreateWidget_Single_Empty()
 {
     RelationController.CreateWidget(_source,
                                     _singleSynonymRelationType,
                                     _singleSynonymRelationField,
                                     _lexEntryRepository,
                                     delegate { });
 }
示例#2
0
 public void CreateWidget_Many()
 {
     RelationController.CreateWidget(_source,
                                     _synonymsRelationType,
                                     _synonymsRelationField,
                                     _lexEntryRepository,
                                     delegate { });
 }
示例#3
0
 public void NoWritingSystemsEnabledOnField_ThrowsConfigurationException()
 {
     _singleSynonymRelationField.WritingSystemIds.Clear();
     Assert.Throws <ConfigurationException>(() => RelationController.CreateWidget(_source,
                                                                                  _singleSynonymRelationType,
                                                                                  _singleSynonymRelationField,
                                                                                  _lexEntryRepository,
                                                                                  delegate { }));
 }
示例#4
0
        public void CreateWidget_Single_ExistingEmpty()
        {
            AddRelation(_source, _singleSynonymRelationField.FieldName, string.Empty);

            RelationController.CreateWidget(_source,
                                            _singleSynonymRelationType,
                                            _singleSynonymRelationField,
                                            _lexEntryRepository,
                                            delegate { });
        }
示例#5
0
        public void CreateWidget_Single_ExistingRelationToExistantRecord_ControlDisplaysLexicalUnit()
        {
            AddRelation(_source, _singleSynonymRelationField.FieldName, _target.Id);

            Control c = RelationController.CreateWidget(_source,
                                                        _singleSynonymRelationType,
                                                        _singleSynonymRelationField,
                                                        _lexEntryRepository,
                                                        delegate { });

            Assert.AreEqual(_target.LexicalForm[WritingSystemsIdsForTests.OtherIdForTest], c.Text);
        }
示例#6
0
        public void CreateWidget_Single_ExistingRelationToNonExistantRecord_ControlDisplaysId()
        {
            AddRelation(_source, _singleSynonymRelationField.FieldName, "NonExistantId");

            Control c = RelationController.CreateWidget(_source,
                                                        _singleSynonymRelationType,
                                                        _singleSynonymRelationField,
                                                        _lexEntryRepository,
                                                        delegate { });

            Assert.AreEqual("NonExistantId", c.Text);
        }
示例#7
0
        public void ChangeBoundRelation_Single_Existing()
        {
            LexRelation relation = AddRelation(_source, _singleSynonymRelationField.FieldName, "something");

            Control c = RelationController.CreateWidget(_source,
                                                        _singleSynonymRelationType,
                                                        _singleSynonymRelationField,
                                                        _lexEntryRepository,
                                                        delegate { });

            c.Text = _target.LexicalForm[WritingSystemsIdsForTests.OtherIdForTest];

            Assert.AreEqual(_target.Id, relation.Key);
        }
示例#8
0
        public void ChangeBoundRelation_Single_ToNonExistant_NoRelation()
        {
            LexRelation relation = AddRelation(_source, _singleSynonymRelationField.FieldName, _target.Id);

            Control c = RelationController.CreateWidget(_source,
                                                        _singleSynonymRelationType,
                                                        _singleSynonymRelationField,
                                                        _lexEntryRepository,
                                                        delegate { });

            c.Text = "NonExistantId";

            Assert.AreEqual(string.Empty, relation.Key);
        }
示例#9
0
        public void TriggerFindApproximate_Single()
        {
            AddRelation(_source, _singleSynonymRelationField.FieldName, _target.Id);

            Control c = RelationController.CreateWidget(_source,
                                                        _singleSynonymRelationType,
                                                        _singleSynonymRelationField,
                                                        _lexEntryRepository,
                                                        delegate { });
            Form form = new Form();

            form.Controls.Add(c);
            AutoCompleteWithCreationBox <RecordToken <LexEntry>, string> picker =
                (AutoCompleteWithCreationBox <RecordToken <LexEntry>, string>)c;

            ((WeSayAutoCompleteTextBox)(picker.Box)).Paste("text");
        }
示例#10
0
        public void ChangeBoundRelation_Single_ToNonExistantCreate_CreatesRelation()
        {
            LexRelation relation = AddRelation(_source, _singleSynonymRelationField.FieldName, _target.Id);

            Control c = RelationController.CreateWidget(_source,
                                                        _singleSynonymRelationType,
                                                        _singleSynonymRelationField,
                                                        _lexEntryRepository,
                                                        delegate { });

            c.Text = "new";

            AutoCompleteWithCreationBox <RecordToken <LexEntry>, string> picker =
                (AutoCompleteWithCreationBox <RecordToken <LexEntry>, string>)c;

            picker.CreateNewObjectFromText();

            LexEntry newEntry = _lexEntryRepository.GetLexEntryWithMatchingId(relation.Key);

            Assert.IsNotNull(newEntry);
            Assert.AreEqual("new", newEntry.LexicalForm[WritingSystemsIdsForTests.OtherIdForTest]);
        }