예제 #1
0
            public void EmptyContentReturnsFalse()
            {
                // Arrange
                IDictionaryDao mockDao = MockRepository.GenerateMock<IDictionaryDao>();

                DictionaryInstance instance = new DictionaryInstance
                                                  {
                                                      Content = string.Empty,
                                                      CultureCode = VALID_CULTURE,
                                                      Item = new DictionaryDataItem
                                                      {
                                                          ItemKey = VALID_KEY
                                                      }
                                                  };

                // make sure we check before dao call
                mockDao.Expect(ddao => ddao.UpsertDictionaryInstance(Arg<DictionaryInstance>.Is.Anything))
                       .Repeat.Never();

                DictionaryManager manager = new DictionaryManager()
                    {
                        DictionaryDao = mockDao
                    };

                // Act
                bool response = manager.UpsertDictionaryInstance(instance);

                // Assert
                Assert.IsFalse(response, "Response should be false");
                mockDao.VerifyAllExpectations();
            }
예제 #2
0
            public void ValidDataCallsMethodsReturnsTrue()
            {
                // Arrange
                IDictionaryDao mockDao = MockRepository.GenerateMock<IDictionaryDao>();

                DictionaryInstance instance = new DictionaryInstance
                {
                    Content = VALID_CONTENT,
                    CultureCode = VALID_CULTURE,
                    Item = new DictionaryDataItem
                    {
                        ItemKey = VALID_KEY
                    }
                };

                // make sure we check before dao call
                mockDao.Expect(ddao => ddao.UpsertDictionaryInstance(Arg<DictionaryInstance>.Matches(dict => dict.Content == instance.Content &&
                                                                                                             dict.CultureCode == instance.CultureCode &&
                                                                                                             dict.Item.ItemKey == instance.Item.ItemKey))).Return(true).Repeat.Once();

                DictionaryManager manager = new DictionaryManager()
                {
                    DictionaryDao = mockDao
                };

                // Act
                bool response = manager.UpsertDictionaryInstance(instance);

                // Assert
                Assert.IsTrue(response, "Response should be true for good data");
                mockDao.VerifyAllExpectations();
            }