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);
    }
    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
    /// <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);
    }
    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);
    }
 public void ShouldCreateInstance(AddVersionCommandProtoype sut, DataStorageSwitcher switcher)
 {
   ReflectionUtil.CallMethod(sut, "CreateInstance").Should().BeOfType<AddVersionCommand>();
 }
 public void ShouldCreateInstance(ResolvePathCommandPrototype sut, DataStorageSwitcher switcher)
 {
   ReflectionUtil.CallMethod(sut, "CreateInstance").Should().BeOfType<ResolvePathCommand>();
 }
 public void ShouldReturnEmptyStringIfNoTemplateFound(FakeStandardValuesProvider sut, [Greedy]Field field, DataStorageSwitcher switcher)
 {
   // act & assert
   sut.GetStandardValue(field).Should().BeEmpty();
 }
 public void ShouldSwitchDataStorage([Frozen]DataStorage dataStorage, DataStorageSwitcher sut)
 {
   Assert.Same(dataStorage, DataStorageSwitcher.CurrentValue(dataStorage.Database.Name));
 }
 public void ShouldCreateInstance(SetBlobStreamCommandPrototype sut, DataStorageSwitcher switcher)
 {
   ReflectionUtil.CallMethod(sut, "CreateInstance").Should().BeOfType<SetBlobStreamCommand>();
 }