コード例 #1
0
    public void ShouldMoveItemToNewDestination(MoveItemCommand sut, GetParentCommandPrototype getParentCommand, Item item, Item destination, ID parentId, DataStorageSwitcher switcher)
    {
      // arrange
      sut.Database.Engines.DataEngine.Commands.GetParentPrototype = getParentCommand;

      var fakeItem = new DbItem("item", item.ID) { ParentID = parentId };
      var fakeParent = new DbItem("parent", parentId) { Children = { fakeItem } };
      var fakeDestination = new DbItem("destination", destination.ID) { FullPath = "/new destination path" };

      sut.DataStorage.GetFakeItem(item.ID).Returns(fakeItem);
      sut.DataStorage.GetFakeItem(parentId).Returns(fakeParent);
      sut.DataStorage.GetFakeItem(destination.ID).Returns(fakeDestination);

      sut.Initialize(item, destination);

      // act
      var result = (bool)ReflectionUtil.CallMethod(sut, "DoExecute");

      // assert
      result.Should().BeTrue();
      fakeItem.ParentID.Should().Be(destination.ID);
      fakeItem.FullPath.Should().Be("/new destination path/item");
      fakeParent.Children.Should().NotContain(fakeItem);
      fakeDestination.Children.Should().Contain(fakeItem);
    }
コード例 #2
0
    public void ShouldGetDataStorageFromSwitcher(DataEngineCommand sut, DataStorageSwitcher switcher)
    {
      // arrange
      var databaseName = sut.DataStorage.Database.Name;

      // act && assert
      sut.DataStorage.Should().Be(DataStorageSwitcher.CurrentValue(databaseName));
    }
コード例 #3
0
ファイル: Db.cs プロジェクト: dharnitski/Sitecore.FakeDb
    /// <summary>
    /// Initializes a new instance of the <see cref="Db"/> class with the specified database.
    /// </summary>
    /// <param name="databaseName">The database name.</param>
    public Db(string databaseName)
    {
      Assert.ArgumentNotNullOrEmpty(databaseName, "databaseName");

      this.database = Database.GetDatabase(databaseName);
      this.dataStorage = new DataStorage(this.database);
      this.dataStorageSwitcher = new DataStorageSwitcher(this.dataStorage);
      this.databaseSwitcher = new DatabaseSwitcher(this.database);

      var args = new InitDbArgs(this.database, this.dataStorage);
      CorePipeline.Run("initFakeDb", args);
    }
コード例 #4
0
    public FakeDataProviderTest()
    {
      var fixture = new Fixture();
      fixture.Customize(
        new CompositeCustomization(
          new DefaultConventions(),
          new AutoNSubstituteCustomization(),
          new AutoConfiguredNSubstituteCustomization()
        ));

      this.dataStorageSwitcher = fixture.Create<DataStorageSwitcher>();
      this.dataProvider = Substitute.ForPartsOf<FakeDataProvider>();
      this.dataProvider.When(provider => provider.DataStorage()).DoNotCallBase();
      this.dataProvider.DataStorage().Returns(info => fixture.Create<DataStorage>());
    }
コード例 #5
0
    /// <summary>
    /// Initializes a new instance of the <see cref="Db"/> class with the specified database.
    /// </summary>
    /// <param name="databaseName">The database name.</param>
    public Db(string databaseName)
    {
      Assert.ArgumentNotNullOrEmpty(databaseName, "databaseName");

      this.database = Database.GetDatabase(databaseName);
      this.dataStorage = new DataStorage(this.database);
      this.dataStorageSwitcher = new DataStorageSwitcher(this.dataStorage);
      this.databaseSwitcher = new DatabaseSwitcher(this.database);
      this.databaseLanguages = new Stack<Switcher<DbLanguages>>();
      this.databaseLanguages.Push(
                  new Switcher<DbLanguages>(
                          new DbLanguages(Language.Parse("en"))));

      var args = new InitDbArgs(this.database, this.dataStorage);
      CorePipeline.Run("initFakeDb", args);
    }
コード例 #6
0
 public void ShouldCreateInstance(AddVersionCommandProtoype sut, DataStorageSwitcher switcher)
 {
   ReflectionUtil.CallMethod(sut, "CreateInstance").Should().BeOfType<AddVersionCommand>();
 }
コード例 #7
0
 public void ShouldCreateInstance(ResolvePathCommandPrototype sut, DataStorageSwitcher switcher)
 {
   ReflectionUtil.CallMethod(sut, "CreateInstance").Should().BeOfType<ResolvePathCommand>();
 }
コード例 #8
0
 public void ShouldReturnEmptyStringIfNoTemplateFound(FakeStandardValuesProvider sut, [Greedy]Field field, DataStorageSwitcher switcher)
 {
   // act & assert
   sut.GetStandardValue(field).Should().BeEmpty();
 }
コード例 #9
0
 public void ShouldSwitchDataStorage([Frozen]DataStorage dataStorage, DataStorageSwitcher sut)
 {
   Assert.Same(dataStorage, DataStorageSwitcher.CurrentValue(dataStorage.Database.Name));
 }
コード例 #10
0
 public void ShouldCreateInstance(SetBlobStreamCommandPrototype sut, DataStorageSwitcher switcher)
 {
   ReflectionUtil.CallMethod(sut, "CreateInstance").Should().BeOfType<SetBlobStreamCommand>();
 }